use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class AddPdxType method cmdExecute.
@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, ClassNotFoundException {
serverConnection.setAsTrue(REQUIRES_RESPONSE);
if (logger.isDebugEnabled()) {
logger.debug("{}: Received get pdx id for type request ({} parts) from {}", serverConnection.getName(), clientMessage.getNumberOfParts(), serverConnection.getSocketString());
}
int noOfParts = clientMessage.getNumberOfParts();
PdxType type = (PdxType) clientMessage.getPart(0).getObject();
int typeId = clientMessage.getPart(1).getInt();
// The native client needs this line
// because it doesn't set the type id on the
// client side.
type.setTypeId(typeId);
try {
InternalCache cache = serverConnection.getCache();
TypeRegistry registry = cache.getPdxRegistry();
registry.addRemoteType(typeId, type);
} catch (Exception e) {
writeException(clientMessage, e, false, serverConnection);
serverConnection.setAsTrue(RESPONDED);
return;
}
writeReply(clientMessage, serverConnection);
serverConnection.setAsTrue(RESPONDED);
}
use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class GetPDXEnumById method cmdExecute.
@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, ClassNotFoundException {
serverConnection.setAsTrue(REQUIRES_RESPONSE);
if (logger.isDebugEnabled()) {
logger.debug("{}: Received get pdx enum by id request ({} parts) from {}", serverConnection.getName(), clientMessage.getNumberOfParts(), serverConnection.getSocketString());
}
int enumId = clientMessage.getPart(0).getInt();
EnumInfo result;
try {
InternalCache cache = serverConnection.getCache();
TypeRegistry registry = cache.getPdxRegistry();
result = registry.getEnumInfoById(enumId);
} catch (Exception e) {
writeException(clientMessage, e, false, serverConnection);
serverConnection.setAsTrue(RESPONDED);
return;
}
Message responseMsg = serverConnection.getResponseMessage();
responseMsg.setMessageType(MessageType.RESPONSE);
responseMsg.setNumberOfParts(1);
responseMsg.setTransactionId(clientMessage.getTransactionId());
responseMsg.addObjPart(result);
responseMsg.send(serverConnection);
serverConnection.setAsTrue(RESPONDED);
}
use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class GetPDXIdForEnum method cmdExecute.
@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, ClassNotFoundException {
serverConnection.setAsTrue(REQUIRES_RESPONSE);
if (logger.isDebugEnabled()) {
logger.debug("{}: Received get pdx id for enum request ({} parts) from {}", serverConnection.getName(), clientMessage.getNumberOfParts(), serverConnection.getSocketString());
}
EnumInfo enumInfo = (EnumInfo) clientMessage.getPart(0).getObject();
int enumId;
try {
InternalCache cache = serverConnection.getCache();
TypeRegistry registry = cache.getPdxRegistry();
enumId = registry.defineEnum(enumInfo);
} catch (Exception e) {
writeException(clientMessage, e, false, serverConnection);
serverConnection.setAsTrue(RESPONDED);
return;
}
Message responseMsg = serverConnection.getResponseMessage();
responseMsg.setMessageType(MessageType.RESPONSE);
responseMsg.setNumberOfParts(1);
responseMsg.setTransactionId(clientMessage.getTransactionId());
responseMsg.addIntPart(enumId);
responseMsg.send(serverConnection);
serverConnection.setAsTrue(RESPONDED);
}
use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class DeployedJar method cleanUp.
/**
* Unregisters all functions from this jar if it was undeployed (i.e. newVersion == null), or all
* functions not present in the new version if it was redeployed.
*
* @param newVersion The new version of this jar that was deployed, or null if this jar was
* undeployed.
*/
protected synchronized void cleanUp(DeployedJar newVersion) {
Stream<String> oldFunctions = this.registeredFunctions.stream().map(Function::getId);
Stream<String> removedFunctions;
if (newVersion == null) {
removedFunctions = oldFunctions;
} else {
Predicate<String> isRemoved = (String oldFunctionId) -> !newVersion.hasFunctionWithId(oldFunctionId);
removedFunctions = oldFunctions.filter(isRemoved);
}
removedFunctions.forEach(FunctionService::unregisterFunction);
this.registeredFunctions.clear();
try {
TypeRegistry typeRegistry = ((InternalCache) CacheFactory.getAnyInstance()).getPdxRegistry();
if (typeRegistry != null) {
typeRegistry.flushCache();
}
} catch (CacheClosedException ignored) {
// That's okay, it just means there was nothing to flush to begin with
}
}
use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class GemFireCacheImplTest method checkPurgeCCPTimer.
@Test
public void checkPurgeCCPTimer() {
InternalDistributedSystem ds = Fakes.distributedSystem();
CacheConfig cc = new CacheConfig();
TypeRegistry typeRegistry = mock(TypeRegistry.class);
SystemTimer ccpTimer = mock(SystemTimer.class);
GemFireCacheImpl gfc = GemFireCacheImpl.createWithAsyncEventListeners(ds, cc, typeRegistry);
try {
gfc.setCCPTimer(ccpTimer);
for (int i = 1; i < GemFireCacheImpl.PURGE_INTERVAL; i++) {
gfc.purgeCCPTimer();
verify(ccpTimer, times(0)).timerPurge();
}
gfc.purgeCCPTimer();
verify(ccpTimer, times(1)).timerPurge();
for (int i = 1; i < GemFireCacheImpl.PURGE_INTERVAL; i++) {
gfc.purgeCCPTimer();
verify(ccpTimer, times(1)).timerPurge();
}
gfc.purgeCCPTimer();
verify(ccpTimer, times(2)).timerPurge();
} finally {
gfc.close();
}
}
Aggregations