use of org.apache.geode.distributed.DurableClientAttributes in project geode by apache.
the class InternalDistributedMember method writeExternal.
/**
* For Externalizable
*
* @see Externalizable
*/
public void writeExternal(ObjectOutput out) throws IOException {
Assert.assertTrue(netMbr.getVmKind() > 0);
// do it the way we like
byte[] address = getInetAddress().getAddress();
// IPv6 compatible
out.writeInt(address.length);
out.write(address);
out.writeInt(getPort());
DataSerializer.writeString(this.hostName, out);
int flags = 0;
if (netMbr.isNetworkPartitionDetectionEnabled())
flags |= NPD_ENABLED_BIT;
if (netMbr.preferredForCoordinator())
flags |= COORD_ENABLED_BIT;
if (this.isPartial)
flags |= PARTIAL_ID_BIT;
// always write product version but enable reading from older versions
// that do not have it
flags |= VERSION_BIT;
out.writeByte((byte) (flags & 0xff));
out.writeInt(netMbr.getDirectPort());
out.writeInt(netMbr.getProcessId());
out.writeInt(netMbr.getVmKind());
out.writeInt(netMbr.getVmViewId());
DataSerializer.writeStringArray(netMbr.getGroups(), out);
DataSerializer.writeString(netMbr.getName(), out);
DataSerializer.writeString(this.uniqueTag, out);
DurableClientAttributes attributes = netMbr.getDurableClientAttributes();
DataSerializer.writeString(attributes == null ? "" : attributes.getId(), out);
DataSerializer.writeInteger(Integer.valueOf(attributes == null ? 300 : attributes.getTimeout()), out);
Version.writeOrdinal(out, netMbr.getVersionOrdinal(), true);
netMbr.writeAdditionalData(out);
}
use of org.apache.geode.distributed.DurableClientAttributes in project geode by apache.
the class InternalDistributedMember method fromDataPre_GFE_7_1_0_0.
public void fromDataPre_GFE_7_1_0_0(DataInput in) throws IOException, ClassNotFoundException {
InetAddress inetAddr = DataSerializer.readInetAddress(in);
int port = in.readInt();
this.hostName = DataSerializer.readString(in);
this.hostName = SocketCreator.resolve_dns ? SocketCreator.getCanonicalHostName(inetAddr, hostName) : inetAddr.getHostAddress();
int flags = in.readUnsignedByte();
boolean sbEnabled = (flags & NPD_ENABLED_BIT) != 0;
boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
this.isPartial = (flags & PARTIAL_ID_BIT) != 0;
int dcPort = in.readInt();
int vmPid = in.readInt();
int vmKind = in.readUnsignedByte();
String[] groups = DataSerializer.readStringArray(in);
int vmViewId = -1;
String name = DataSerializer.readString(in);
if (vmKind == DistributionManager.LONER_DM_TYPE) {
this.uniqueTag = DataSerializer.readString(in);
} else {
String str = DataSerializer.readString(in);
if (str != null) {
// backward compatibility from earlier than 6.5
vmViewId = Integer.parseInt(str);
}
}
String durableId = DataSerializer.readString(in);
int durableTimeout = DataSerializer.readInteger(in).intValue();
DurableClientAttributes durableClientAttributes = durableId.length() > 0 ? new DurableClientAttributes(durableId, durableTimeout) : null;
short version = readVersion(flags, in);
MemberAttributes attr = new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups, durableClientAttributes);
netMbr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord, version, attr);
Assert.assertTrue(netMbr.getVmKind() > 0);
}
use of org.apache.geode.distributed.DurableClientAttributes in project geode by apache.
the class InternalDistributedMember method fromDataPre_GFE_9_0_0_0.
public void fromDataPre_GFE_9_0_0_0(DataInput in) throws IOException, ClassNotFoundException {
InetAddress inetAddr = DataSerializer.readInetAddress(in);
int port = in.readInt();
this.hostName = DataSerializer.readString(in);
this.hostName = SocketCreator.resolve_dns ? SocketCreator.getCanonicalHostName(inetAddr, hostName) : inetAddr.getHostAddress();
int flags = in.readUnsignedByte();
boolean sbEnabled = (flags & NPD_ENABLED_BIT) != 0;
boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
this.isPartial = (flags & PARTIAL_ID_BIT) != 0;
int dcPort = in.readInt();
int vmPid = in.readInt();
int vmKind = in.readUnsignedByte();
String[] groups = DataSerializer.readStringArray(in);
int vmViewId = -1;
String name = DataSerializer.readString(in);
if (vmKind == DistributionManager.LONER_DM_TYPE) {
this.uniqueTag = DataSerializer.readString(in);
} else {
String str = DataSerializer.readString(in);
if (str != null) {
// backward compatibility from earlier than 6.5
vmViewId = Integer.parseInt(str);
}
}
String durableId = DataSerializer.readString(in);
int durableTimeout = DataSerializer.readInteger(in).intValue();
DurableClientAttributes durableClientAttributes = durableId.length() > 0 ? new DurableClientAttributes(durableId, durableTimeout) : null;
short version = readVersion(flags, in);
MemberAttributes attr = new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups, durableClientAttributes);
netMbr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord, version, attr);
Assert.assertTrue(netMbr.getVmKind() > 0);
// Assert.assertTrue(getPort() > 0);
}
use of org.apache.geode.distributed.DurableClientAttributes in project geode by apache.
the class LonerDistributionManager method generateMemberId.
// private static final int CHARS_32KB = 16384;
private InternalDistributedMember generateMemberId() {
InternalDistributedMember result = null;
String host;
try {
// create string of the current millisecond clock time
StringBuffer sb = new StringBuffer();
// use low four bytes for backward compatibility
long time = System.currentTimeMillis() & 0xffffffffL;
for (int i = 0; i < 4; i++) {
String hex = Integer.toHexString((int) (time & 0xff));
if (hex.length() < 2) {
sb.append('0');
}
sb.append(hex);
time = time / 0x100;
}
String uniqueString = sb.toString();
String name = this.system.getName();
InetAddress hostAddr = SocketCreator.getLocalHost();
host = SocketCreator.use_client_host_name ? hostAddr.getCanonicalHostName() : hostAddr.getHostAddress();
DistributionConfig config = system.getConfig();
DurableClientAttributes dac = null;
if (config.getDurableClientId() != null) {
dac = new DurableClientAttributes(config.getDurableClientId(), config.getDurableClientTimeout());
}
result = new InternalDistributedMember(host, lonerPort, name, uniqueString, DistributionManager.LONER_DM_TYPE, MemberAttributes.parseGroups(config.getRoles(), config.getGroups()), dac);
} catch (UnknownHostException ex) {
throw new InternalGemFireError(LocalizedStrings.LonerDistributionManager_CANNOT_RESOLVE_LOCAL_HOST_NAME_TO_AN_IP_ADDRESS.toLocalizedString());
}
return result;
}
Aggregations