use of org.apache.geode.internal.Version in project geode by apache.
the class OldClientSupportProvider method processOutgoingClassName.
@Override
public String processOutgoingClassName(String name, DataOutput out) {
// tcpserver was moved to a different package
String oldPackage = "com.gemstone.org.jgroups.stack.tcpserver";
String newPackage = "org.apache.geode.distributed.internal.tcpserver";
if (name.startsWith(newPackage)) {
return oldPackage + name.substring(newPackage.length());
}
if (ALWAYS_CONVERT_CLASSES) {
return processClassName(name, GEODE, GEMFIRE, newClassNamesToOld);
}
// if the client is old then it needs com.gemstone.gemfire package names
if (out instanceof VersionedDataOutputStream) {
VersionedDataOutputStream vout = (VersionedDataOutputStream) out;
Version version = vout.getVersion();
if (version != null && version.compareTo(Version.GFE_90) < 0) {
return processClassName(name, GEODE, GEMFIRE, newClassNamesToOld);
}
}
return name;
}
use of org.apache.geode.internal.Version in project geode by apache.
the class RemoveAllPRMessage method fromData.
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
super.fromData(in);
this.bucketId = Integer.valueOf((int) InternalDataSerializer.readSignedVL(in));
if ((flags & HAS_BRIDGE_CONTEXT) != 0) {
this.bridgeContext = DataSerializer.readObject(in);
}
Version sourceVersion = InternalDataSerializer.getVersionForDataStream(in);
this.callbackArg = DataSerializer.readObject(in);
this.removeAllPRDataSize = (int) InternalDataSerializer.readUnsignedVL(in);
this.removeAllPRData = new RemoveAllEntryData[removeAllPRDataSize];
if (this.removeAllPRDataSize > 0) {
final Version version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
final ByteArrayDataInput bytesIn = new ByteArrayDataInput();
for (int i = 0; i < this.removeAllPRDataSize; i++) {
this.removeAllPRData[i] = new RemoveAllEntryData(in, null, i, version, bytesIn);
}
boolean hasTags = in.readBoolean();
if (hasTags) {
EntryVersionsList versionTags = EntryVersionsList.create(in);
for (int i = 0; i < this.removeAllPRDataSize; i++) {
this.removeAllPRData[i].versionTag = versionTags.get(i);
}
}
}
}
use of org.apache.geode.internal.Version in project geode by apache.
the class ServerHandShakeProcessor method readClientVersion.
private static Version readClientVersion(ServerConnection connection) throws IOException, VersionException {
Socket socket = connection.getSocket();
int timeout = connection.getHandShakeTimeout();
int soTimeout = -1;
try {
soTimeout = socket.getSoTimeout();
socket.setSoTimeout(timeout);
InputStream is = socket.getInputStream();
short clientVersionOrdinal = Version.readOrdinalFromInputStream(is);
if (clientVersionOrdinal == -1) {
throw new EOFException(LocalizedStrings.ServerHandShakeProcessor_HANDSHAKEREADER_EOF_REACHED_BEFORE_CLIENT_VERSION_COULD_BE_READ.toLocalizedString());
}
Version clientVersion = null;
try {
clientVersion = Version.fromOrdinal(clientVersionOrdinal, true);
} catch (UnsupportedVersionException uve) {
// Allows higher version of wan site to connect to server
if (connection.getCommunicationMode() == Acceptor.GATEWAY_TO_GATEWAY && !(clientVersionOrdinal == Version.NOT_SUPPORTED_ORDINAL)) {
return Acceptor.VERSION;
} else {
SocketAddress sa = socket.getRemoteSocketAddress();
String sInfo = "";
if (sa != null) {
sInfo = " Client: " + sa.toString() + ".";
}
throw new UnsupportedVersionException(uve.getMessage() + sInfo);
}
}
if (!clientVersion.compatibleWith(Acceptor.VERSION)) {
// we can throw this
throw new IncompatibleVersionException(clientVersion, Acceptor.VERSION);
// to restrict
}
// Backward Compatibilty Support to limited no of versions
return clientVersion;
} finally {
if (soTimeout != -1) {
try {
socket.setSoTimeout(soTimeout);
} catch (IOException ignore) {
}
}
}
}
use of org.apache.geode.internal.Version in project geode by apache.
the class GMSLocator method recoverFromFile.
/* package */
boolean recoverFromFile(File file) throws InternalGemFireException {
if (!file.exists()) {
logger.info("recovery file not found: " + file.getAbsolutePath());
return false;
}
logger.info("Peer locator recovering from " + file.getAbsolutePath());
try (ObjectInput ois = new ObjectInputStream(new FileInputStream(file))) {
if (ois.readInt() != LOCATOR_FILE_STAMP) {
return false;
}
ObjectInput ois2 = ois;
int version = ois2.readInt();
if (version != Version.CURRENT_ORDINAL) {
Version geodeVersion = Version.fromOrdinalNoThrow((short) version, false);
logger.info("Peer locator found that persistent view was written with {}", geodeVersion);
ois2 = new VersionedObjectInput(ois2, geodeVersion);
}
Object o = DataSerializer.readObject(ois2);
this.view = (NetView) o;
logger.info("Peer locator initial membership is " + view);
return true;
} catch (Exception e) {
String msg = LOCATOR_UNABLE_TO_RECOVER_VIEW.toLocalizedString(file.toString());
logger.warn(msg, e);
if (!file.delete() && file.exists()) {
logger.warn("Peer locator was unable to recover from or delete " + file);
this.viewFile = null;
}
throw new InternalGemFireException(msg, e);
}
}
use of org.apache.geode.internal.Version in project geode by apache.
the class PutAllPRMessage method fromData.
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
super.fromData(in);
this.bucketId = (int) InternalDataSerializer.readSignedVL(in);
if ((flags & HAS_BRIDGE_CONTEXT) != 0) {
this.bridgeContext = DataSerializer.readObject(in);
}
this.callbackArg = DataSerializer.readObject(in);
this.putAllPRDataSize = (int) InternalDataSerializer.readUnsignedVL(in);
this.putAllPRData = new PutAllEntryData[putAllPRDataSize];
if (this.putAllPRDataSize > 0) {
final Version version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
final ByteArrayDataInput bytesIn = new ByteArrayDataInput();
for (int i = 0; i < this.putAllPRDataSize; i++) {
this.putAllPRData[i] = new PutAllEntryData(in, null, i, version, bytesIn);
}
boolean hasTags = in.readBoolean();
if (hasTags) {
EntryVersionsList versionTags = EntryVersionsList.create(in);
for (int i = 0; i < this.putAllPRDataSize; i++) {
this.putAllPRData[i].versionTag = versionTags.get(i);
}
}
}
}
Aggregations