use of org.infinispan.util.ByteString in project infinispan by infinispan.
the class GlobalInboundInvocationHandler method cacheStopped.
@CacheStopped
public void cacheStopped(CacheStoppedEvent event) {
ByteString cacheName = ByteString.fromString(event.getCacheName());
localCachesMap.entrySet().removeIf(entry -> entry.getValue().cacheName.equals(cacheName));
}
use of org.infinispan.util.ByteString in project infinispan by infinispan.
the class GlobalInboundInvocationHandler method handleCacheRpcCommand.
private void handleCacheRpcCommand(Address origin, CacheRpcCommand command, Reply reply, DeliverOrder mode) {
if (log.isTraceEnabled()) {
log.tracef("Attempting to execute CacheRpcCommand: %s [sender=%s]", command, origin);
}
ByteString cacheName = command.getCacheName();
ComponentRegistry cr = globalComponentRegistry.getNamedComponentRegistry(cacheName);
if (cr == null) {
if (log.isTraceEnabled()) {
log.tracef("Silently ignoring that %s cache is not defined", cacheName);
}
reply.reply(CacheNotFoundResponse.INSTANCE);
return;
}
CommandsFactory commandsFactory = cr.getCommandsFactory();
// initialize this command with components specific to the intended cache instance
commandsFactory.initializeReplicableCommand(command, true);
PerCacheInboundInvocationHandler handler = cr.getPerCacheInboundInvocationHandler();
handler.handle(command, reply, mode);
}
use of org.infinispan.util.ByteString in project infinispan by infinispan.
the class VersionAwareMarshallerTest method testReplicableCommandsMarshalling.
public void testReplicableCommandsMarshalling() throws Exception {
ByteString cacheName = ByteString.fromString(TestingUtil.getDefaultCacheName(cm));
ClusteredGetCommand c2 = new ClusteredGetCommand("key", cacheName, 0, EnumUtil.EMPTY_BIT_SET);
marshallAndAssertEquality(c2);
// SizeCommand does not have an empty constructor, so doesn't look to be one that is marshallable.
GetKeyValueCommand c4 = new GetKeyValueCommand("key", 0, EnumUtil.EMPTY_BIT_SET);
marshallAndAssertEquality(c4);
PutKeyValueCommand c5 = new PutKeyValueCommand("k", "v", false, new EmbeddedMetadata.Builder().build(), 0, EnumUtil.EMPTY_BIT_SET, CommandInvocationId.generateId(null));
marshallAndAssertEquality(c5);
RemoveCommand c6 = new RemoveCommand("key", null, 0, EnumUtil.EMPTY_BIT_SET, CommandInvocationId.generateId(null));
marshallAndAssertEquality(c6);
// EvictCommand does not have an empty constructor, so doesn't look to be one that is marshallable.
InvalidateCommand c7 = new InvalidateCommand(EnumUtil.EMPTY_BIT_SET, CommandInvocationId.generateId(null), "key1", "key2");
marshallAndAssertEquality(c7);
InvalidateCommand c71 = new InvalidateL1Command(EnumUtil.EMPTY_BIT_SET, CommandInvocationId.generateId(null), "key1", "key2");
marshallAndAssertEquality(c71);
ReplaceCommand c8 = new ReplaceCommand("key", "oldvalue", "newvalue", new EmbeddedMetadata.Builder().build(), 0, EnumUtil.EMPTY_BIT_SET, CommandInvocationId.generateId(null));
marshallAndAssertEquality(c8);
ClearCommand c9 = new ClearCommand();
marshallAndAssertEquality(c9);
Map<Integer, GlobalTransaction> m1 = new HashMap<>();
for (int i = 0; i < 10; i++) {
GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(UUID.randomUUID()), false);
m1.put(1000 * i, gtx);
}
PutMapCommand c10 = new PutMapCommand(m1, new EmbeddedMetadata.Builder().build(), EnumUtil.EMPTY_BIT_SET, CommandInvocationId.generateId(null));
marshallAndAssertEquality(c10);
Address local = new JGroupsAddress(UUID.randomUUID());
GlobalTransaction gtx = gtf.newGlobalTransaction(local, false);
PrepareCommand c11 = new PrepareCommand(cacheName, gtx, true, c5, c6, c8, c10);
marshallAndAssertEquality(c11);
CommitCommand c12 = new CommitCommand(cacheName, gtx);
marshallAndAssertEquality(c12);
RollbackCommand c13 = new RollbackCommand(cacheName, gtx);
marshallAndAssertEquality(c13);
}
use of org.infinispan.util.ByteString in project infinispan by infinispan.
the class WeakCounterImpl method initKeys.
private static Entry[] initKeys(String counterName, int concurrencyLevel) {
ByteString name = ByteString.fromString(counterName);
int size = Util.findNextHighestPowerOfTwo(concurrencyLevel);
Entry[] entries = new Entry[size];
for (int i = 0; i < size; ++i) {
entries[i] = new Entry(new WeakCounterKey(name, i));
}
return entries;
}
use of org.infinispan.util.ByteString in project infinispan by infinispan.
the class BaseIracPersistenceTest method createMetadata.
private static IracMetadata createMetadata() {
TopologyIracVersion version = TopologyIracVersion.create(1, V_GENERATOR.incrementAndGet());
ByteString site = XSiteNamedCache.cachedByteString(SITE);
return new IracMetadata(site, IracEntryVersion.newVersion(site, version));
}
Aggregations