use of org.apache.geode.distributed.DurableClientAttributes in project geode by apache.
the class InternalDistributedMember method readExternal.
/**
* For Externalizable
*
* @see Externalizable
*/
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
// IPv6 compatible
int len = in.readInt();
byte[] addr = new byte[len];
in.readFully(addr);
InetAddress inetAddr = InetAddress.getByAddress(addr);
int port = in.readInt();
this.hostName = DataSerializer.readString(in);
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.readInt();
int vmViewId = in.readInt();
String[] groups = DataSerializer.readStringArray(in);
String name = DataSerializer.readString(in);
this.uniqueTag = DataSerializer.readString(in);
String durableId = DataSerializer.readString(in);
int durableTimeout = DataSerializer.readInteger(in).intValue();
DurableClientAttributes durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);
short version = readVersion(flags, in);
netMbr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord, version, new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups, durableClientAttributes));
if (version >= Version.GFE_90.ordinal()) {
try {
netMbr.readAdditionalData(in);
} catch (java.io.EOFException e) {
// old version
}
}
Assert.assertTrue(netMbr.getVmKind() > 0);
}
use of org.apache.geode.distributed.DurableClientAttributes in project geode by apache.
the class InternalDistributedMember method toDataPre_GFE_7_1_0_0.
public void toDataPre_GFE_7_1_0_0(DataOutput out) throws IOException {
Assert.assertTrue(netMbr.getVmKind() > 0);
// disabled to allow post-connect setting of the port for loner systems
// Assert.assertTrue(getPort() > 0);
// if (this.getPort() == 0) {
// InternalDistributedSystem.getLoggerI18n().warning(LocalizedStrings.DEBUG,
// "Serializing ID with zero port", new Exception("Stack trace"));
// }
// NOTE: If you change the serialized format of this class
// then bump Connection.HANDSHAKE_VERSION since an
// instance of this class is sent during Connection handshake.
DataSerializer.writeInetAddress(getInetAddress(), out);
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;
out.writeByte((byte) (flags & 0xff));
out.writeInt(netMbr.getDirectPort());
out.writeInt(netMbr.getProcessId());
out.writeByte(netMbr.getVmKind());
DataSerializer.writeStringArray(netMbr.getGroups(), out);
DataSerializer.writeString(netMbr.getName(), out);
int vmKind = netMbr.getVmKind();
if (vmKind == DistributionManager.LONER_DM_TYPE) {
DataSerializer.writeString(this.uniqueTag, out);
} else {
// added in 6.5 for unique identifiers in P2P
DataSerializer.writeString(String.valueOf(netMbr.getVmViewId()), out);
}
DurableClientAttributes durableClientAttributes = netMbr.getDurableClientAttributes();
DataSerializer.writeString(durableClientAttributes == null ? "" : durableClientAttributes.getId(), out);
DataSerializer.writeInteger(Integer.valueOf(durableClientAttributes == null ? 300 : durableClientAttributes.getTimeout()), out);
}
use of org.apache.geode.distributed.DurableClientAttributes in project geode by apache.
the class JGroupsMessenger method establishLocalAddress.
private void establishLocalAddress() {
UUID logicalAddress = (UUID) myChannel.getAddress();
logicalAddress = logicalAddress.copy();
IpAddress ipaddr = (IpAddress) myChannel.down(new Event(Event.GET_PHYSICAL_ADDRESS));
if (ipaddr != null) {
this.jgAddress = new JGAddress(logicalAddress, ipaddr);
} else {
UDP udp = (UDP) myChannel.getProtocolStack().getTransport();
try {
Method getAddress = UDP.class.getDeclaredMethod("getPhysicalAddress");
getAddress.setAccessible(true);
ipaddr = (IpAddress) getAddress.invoke(udp, new Object[0]);
this.jgAddress = new JGAddress(logicalAddress, ipaddr);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
logger.info("Unable to find getPhysicallAddress method in UDP - parsing its address instead");
}
// if (this.jgAddress == null) {
// String addr = udp.getLocalPhysicalAddress();
// int cidx = addr.lastIndexOf(':'); // IPv6 literals might have colons
// String host = addr.substring(0, cidx);
// int jgport = Integer.parseInt(addr.substring(cidx+1, addr.length()));
// try {
// this.jgAddress = new JGAddress(logicalAddress, new IpAddress(InetAddress.getByName(host),
// jgport));
// } catch (UnknownHostException e) {
// myChannel.disconnect();
// throw new SystemConnectException("unable to initialize jgroups address", e);
// }
// }
}
// install the address in the JGroups channel protocols
myChannel.down(new Event(Event.SET_LOCAL_ADDRESS, this.jgAddress));
DistributionConfig config = services.getConfig().getDistributionConfig();
boolean isLocator = (services.getConfig().getTransport().getVmKind() == DistributionManager.LOCATOR_DM_TYPE) || !services.getConfig().getDistributionConfig().getStartLocator().isEmpty();
// establish the DistributedSystem's address
DurableClientAttributes dca = null;
if (config.getDurableClientId() != null) {
dca = new DurableClientAttributes(config.getDurableClientId(), config.getDurableClientTimeout());
}
MemberAttributes attr = new MemberAttributes(-1, /* dcPort - not known at this time */
OSProcess.getId(), services.getConfig().getTransport().getVmKind(), -1, /* view id - not known at this time */
config.getName(), MemberAttributes.parseGroups(config.getRoles(), config.getGroups()), dca);
localAddress = new InternalDistributedMember(jgAddress.getInetAddress(), jgAddress.getPort(), config.getEnableNetworkPartitionDetection(), isLocator, attr);
// add the JGroups logical address to the GMSMember
UUID uuid = this.jgAddress;
GMSMember gmsMember = (GMSMember) localAddress.getNetMember();
gmsMember.setUUID(uuid);
gmsMember.setMemberWeight((byte) (services.getConfig().getMemberWeight() & 0xff));
gmsMember.setNetworkPartitionDetectionEnabled(services.getConfig().getDistributionConfig().getEnableNetworkPartitionDetection());
}
use of org.apache.geode.distributed.DurableClientAttributes in project geode by apache.
the class InternalDistributedMember method getDurableClientAttributes.
/**
* Returns this client member's durable attributes or null if no durable attributes were created.
*/
public DurableClientAttributes getDurableClientAttributes() {
assert !this.isPartial;
DurableClientAttributes attributes = netMbr.getDurableClientAttributes();
if (attributes == null) {
attributes = new DurableClientAttributes("", 300);
netMbr.setDurableClientAttributes(attributes);
}
return netMbr.getDurableClientAttributes();
}
use of org.apache.geode.distributed.DurableClientAttributes in project geode by apache.
the class InternalDistributedMember method toDataPre_GFE_9_0_0_0.
public void toDataPre_GFE_9_0_0_0(DataOutput out) throws IOException {
// Assert.assertTrue(vmKind > 0);
// NOTE: If you change the serialized format of this class
// then bump Connection.HANDSHAKE_VERSION since an
// instance of this class is sent during Connection handshake.
DataSerializer.writeInetAddress(getInetAddress(), out);
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());
int vmKind = netMbr.getVmKind();
out.writeByte(vmKind);
DataSerializer.writeStringArray(netMbr.getGroups(), out);
DataSerializer.writeString(netMbr.getName(), out);
if (vmKind == DistributionManager.LONER_DM_TYPE) {
DataSerializer.writeString(this.uniqueTag, out);
} else {
// added in 6.5 for unique identifiers in P2P
DataSerializer.writeString(String.valueOf(netMbr.getVmViewId()), out);
}
DurableClientAttributes durableClientAttributes = netMbr.getDurableClientAttributes();
DataSerializer.writeString(durableClientAttributes == null ? "" : durableClientAttributes.getId(), out);
DataSerializer.writeInteger(Integer.valueOf(durableClientAttributes == null ? 300 : durableClientAttributes.getTimeout()), out);
short version = netMbr.getVersionOrdinal();
Version.writeOrdinal(out, version, true);
}
Aggregations