Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade JavaScript to use getIceProperty #2997

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions csharp/src/Ice/Internal/ReferenceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ internal Reference create(string s, string propertyPrefix)
throw new ParseException($"invalid endpoint '{unknownEndpoints[0]}' in '{s}'");
}
else if (unknownEndpoints.Count != 0 &&
_instance.initializationData().properties.getPropertyAsIntWithDefault(
"Ice.Warn.Endpoints", 1) > 0)
_instance.initializationData().properties.getIcePropertyAsInt("Ice.Warn.Endpoints") > 0)
{
StringBuilder msg = new StringBuilder("Proxy contains unknown endpoints:");
int sz = unknownEndpoints.Count;
Expand Down
2 changes: 1 addition & 1 deletion js/src/Ice/ConnectionI.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class ConnectionI {

this._hasMoreData = { value: false };

this._warn = initData.properties.getPropertyAsInt("Ice.Warn.Connections") > 0;
this._warn = initData.properties.getIcePropertyAsInt("Ice.Warn.Connections") > 0;
this._nextRequestId = 1;
this._messageSizeMax = instance.messageSizeMax();
this._batchRequestQueue = new BatchRequestQueue(instance);
Expand Down
39 changes: 16 additions & 23 deletions js/src/Ice/DefaultsAndOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { FormatType } from "./FormatType.js";
import { EndpointSelectionType } from "./EndpointSelectionType.js";
import { Protocol, stringToEncodingVersion, encodingVersionToString } from "./Protocol.js";
import { Protocol, stringToEncodingVersion } from "./Protocol.js";
import { ParseException } from "./LocalExceptions.js";
import { TcpTransceiver } from "./TcpTransceiver.js";

Expand All @@ -15,53 +15,46 @@ export class DefaultsAndOverrides {
TcpTransceiver !== null ? "tcp" : "ws",
);

let value = properties.getProperty("Ice.Default.Host");
let value = properties.getIceProperty("Ice.Default.Host");
this.defaultHost = value.length > 0 ? value : null;

value = properties.getProperty("Ice.Default.SourceAddress");
value = properties.getIceProperty("Ice.Default.SourceAddress");
this.defaultSourceAddress = value.length > 0 ? value : null;

this.overrideSecure = false;

value = properties.getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
value = properties.getIceProperty("Ice.Default.EndpointSelection");
if (value === "Random") {
this.defaultEndpointSelection = EndpointSelectionType.Random;
} else if (value === "Ordered") {
this.defaultEndpointSelection = EndpointSelectionType.Ordered;
} else {
throw new ParseException(`illegal value '${value}'; expected 'Random' or 'Ordered'`);
throw new ParseException(
`illegal value '${value}' in property Ice.Default.EndpointSelection; expected 'Random' or 'Ordered'`,
);
}

this.defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
this.defaultLocatorCacheTimeout = properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout");
if (this.defaultLocatorCacheTimeout < -1) {
this.defaultLocatorCacheTimeout = -1;
logger.warning(
"invalid value for Ice.Default.LocatorCacheTimeout `" +
properties.getProperty("Ice.Default.LocatorCacheTimeout") +
"': defaulting to -1",
throw new InitializationException(
`invalid value for Ice.Default.LocatorCacheTimeout '${this.defaultLocatorCacheTimeout}'`,
);
}

this.defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
this.defaultInvocationTimeout = properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout");
if (this.defaultInvocationTimeout < 1 && this.defaultInvocationTimeout !== -1) {
this.defaultInvocationTimeout = -1;
logger.warning(
"invalid value for Ice.Default.InvocationTimeout `" +
properties.getProperty("Ice.Default.InvocationTimeout") +
"': defaulting to -1",
throw new InitializationException(
`invalid value for Ice.Default.InvocationTimeout '${this.defaultInvocationTimeout}'`,
);
}

this.defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
this.defaultPreferSecure = properties.getIcePropertyAsInt("Ice.Default.PreferSecure") > 0;

value = properties.getPropertyWithDefault(
"Ice.Default.EncodingVersion",
encodingVersionToString(Protocol.currentEncoding),
);
value = properties.getIceProperty("Ice.Default.EncodingVersion");
this.defaultEncoding = stringToEncodingVersion(value);
Protocol.checkSupportedEncoding(this.defaultEncoding);

const slicedFormat = properties.getPropertyAsIntWithDefault("Ice.Default.SlicedFormat", 0) > 0;
const slicedFormat = properties.getIcePropertyAsInt("Ice.Default.SlicedFormat") > 0;
this.defaultFormat = slicedFormat ? FormatType.SlicedFormat : FormatType.CompactFormat;
}
}
17 changes: 9 additions & 8 deletions js/src/Ice/InstanceExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ Instance.prototype.finishSetup = function (communicator) {

this._defaultsAndOverrides = new DefaultsAndOverrides(this._initData.properties, this._initData.logger);

const defMessageSizeMax = 1024;
let num = this._initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defMessageSizeMax);
let num = this._initData.properties.getIcePropertyAsInt("Ice.MessageSizeMax");
if (num < 1 || num > 0x7fffffff / 1024) {
this._messageSizeMax = 0x7fffffff;
} else {
Expand All @@ -209,11 +208,11 @@ Instance.prototype.finishSetup = function (communicator) {
this._initData.properties.getProperty("Ice.BatchAutoFlushSize").length === 0 &&
this._initData.properties.getProperty("Ice.BatchAutoFlush").length > 0
) {
if (this._initData.properties.getPropertyAsInt("Ice.BatchAutoFlush") > 0) {
if (this._initData.properties.getIcePropertyAsInt("Ice.BatchAutoFlush") > 0) {
this._batchAutoFlushSize = this._messageSizeMax;
}
} else {
num = this._initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlushSize", 1024); // 1MB
num = this._initData.properties.getIcePropertyAsInt("Ice.BatchAutoFlushSize");
if (num < 1) {
this._batchAutoFlushSize = num;
} else if (num > 0x7fffffff / 1024) {
Expand All @@ -230,16 +229,18 @@ Instance.prototype.finishSetup = function (communicator) {
this._classGraphDepthMax = num;
}

const toStringModeStr = this._initData.properties.getPropertyWithDefault("Ice.ToStringMode", "Unicode");
const toStringModeStr = this._initData.properties.getIceProperty("Ice.ToStringMode");
if (toStringModeStr === "ASCII") {
this._toStringMode = ToStringMode.ASCII;
} else if (toStringModeStr === "Compat") {
this._toStringMode = ToStringMode.Compat;
} else if (toStringModeStr !== "Unicode") {
throw new InitializationException("The value for Ice.ToStringMode must be Unicode, ASCII or Compat");
throw new InitializationException(
`illegal value '${toStringModeStr}' in property Ice.ToStringMode; expected 'Unicode', 'ASCII', or 'Compat'`,
);
}

this._implicitContext = ImplicitContext.create(this._initData.properties.getProperty("Ice.ImplicitContext"));
this._implicitContext = ImplicitContext.create(this._initData.properties.getIceProperty("Ice.ImplicitContext"));

this._routerManager = new RouterManager();

Expand Down Expand Up @@ -274,7 +275,7 @@ Instance.prototype.finishSetup = function (communicator) {
this._objectAdapterFactory = new ObjectAdapterFactory(this, communicator);

this._retryQueue = new RetryQueue(this);
const retryIntervals = this._initData.properties.getPropertyAsList("Ice.RetryIntervals");
const retryIntervals = this._initData.properties.getIcePropertyAsList("Ice.RetryIntervals");
if (retryIntervals.length > 0) {
this._retryIntervals = [];

Expand Down
2 changes: 1 addition & 1 deletion js/src/Ice/LocatorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { LocatorTable } from "./LocatorTable.js";

export class LocatorManager {
constructor(properties) {
this._background = properties.getPropertyAsInt("Ice.BackgroundLocatorCacheUpdates") > 0;
this._background = properties.getIcePropertyAsInt("Ice.BackgroundLocatorCacheUpdates") > 0;
this._table = new HashMap(HashMap.compareEquals); // Map<Ice.LocatorPrx, LocatorInfo>
this._locatorTables = new HashMap(HashMap.compareEquals); // Map<Ice.Identity, LocatorTable>
}
Expand Down
30 changes: 10 additions & 20 deletions js/src/Ice/TraceLevels.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,51 @@
//

export function TraceLevels(properties) {
const networkCat = "Network";
const protocolCat = "Protocol";
const retryCat = "Retry";
const locationCat = "Locator";
const slicingCat = "Slicing";

const keyBase = "Ice.Trace.";

const network = properties.getPropertyAsInt(keyBase + networkCat);
const protocol = properties.getPropertyAsInt(keyBase + protocolCat);
const retry = properties.getPropertyAsInt(keyBase + retryCat);
const location = properties.getPropertyAsInt(keyBase + locationCat);
const slicing = properties.getPropertyAsInt(keyBase + slicingCat);

properties.getPropertyAsInt(keyBase + "ThreadPool"); // Avoid an "unused property" warning.
const network = properties.getPropertyAsInt("Ice.Trace.Network");
const protocol = properties.getPropertyAsInt("Ice.Trace.Protocol");
const retry = properties.getPropertyAsInt("Ice.Trace.Retry");
const location = properties.getPropertyAsInt("Ice.Trace.Locator");
const slicing = properties.getPropertyAsInt("Ice.Trace.Slicing");

return class {
static get network() {
return network;
}

static get networkCat() {
return networkCat;
return "Network";
}

static get protocol() {
return protocol;
}

static get protocolCat() {
return protocolCat;
return "Protocol";
}

static get retry() {
return retry;
}

static get retryCat() {
return retryCat;
return "Retry";
}

static get location() {
return location;
}

static get locationCat() {
return locationCat;
return "Locator";
}

static get slicing() {
return slicing;
}

static get slicingCat() {
return slicingCat;
return "Slicing";
}
};
}
Loading