use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class MergePolicySerializationTest method testIssue2665.
@Test
public void testIssue2665() {
String name = randomString();
String serviceName = "hz:impl:mapService";
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<String, MyObject> map = instance.getMap(name);
MyObject myObjectExisting = new MyObject();
map.put("key", myObjectExisting);
NodeEngineImpl nodeEngine = HazelcastTestSupport.getNode(instance).getNodeEngine();
MapService mapService = nodeEngine.getService(serviceName);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
int partitionId = nodeEngine.getPartitionService().getPartitionId("key");
Data dataKey = mapServiceContext.toData("key");
RecordStore recordStore = mapServiceContext.getRecordStore(partitionId, name);
MapMergePolicy mergePolicy = mapServiceContext.getMergePolicyProvider().getMergePolicy(PutIfAbsentMapMergePolicy.class.getName());
EntryView<String, MyObject> mergingEntryView = new SimpleEntryView<String, MyObject>("key", new MyObject());
recordStore.merge(dataKey, mergingEntryView, mergePolicy);
int deSerializedCount = MyObject.deserializedCount;
assertEquals(0, deSerializedCount);
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class MapPutAllWrongTargetForPartitionTest method testPutAllPerMemberOperation.
/**
* Tests that all entries and backups of a {@link PutAllPartitionAwareOperationFactory} are sent to the correct members.
* <p/>
* The test creates a cluster with a single partition per member and invokes {@link PutAllPartitionAwareOperationFactory}
* which contains a single entry for every partition in the cluster. So just a single entry is for the member the factory
* is executed on.
* <p/>
* After the operation is invoked we assert that each member owns one entry of the map and that all backups have been written.
*/
private void testPutAllPerMemberOperation(final int entriesPerPartition) throws Exception {
final int expectedEntryCount = INSTANCE_COUNT * entriesPerPartition;
final String mapName = randomMapName();
HazelcastInstance hz = instances[0];
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
SerializationService serializationService = nodeEngine.getSerializationService();
// create a PutAllPerMemberOperation with entries for all partitions
PartitionAwareOperationFactory factory = createPutAllOperationFactory(entriesPerPartition, mapName, hz, serializationService);
// invoke the operation on a random remote target
InternalOperationService operationService = nodeEngine.getOperationService();
operationService.invokeOnPartitions(MapService.SERVICE_NAME, factory, factory.getPartitions());
// assert that all entries have been written
IMap<String, String> map = hz.getMap(mapName);
assertEquals(format("Expected %d entries in the map", expectedEntryCount), expectedEntryCount, map.size());
for (Map.Entry<String, String> entry : map.entrySet()) {
assertEquals("Expected that key and value are the same", entry.getKey(), entry.getValue());
}
// assert that each member owns entriesPerPartition entries of the map and that all backups have been written
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
int totalBackups = 0;
for (int i = 0; i < INSTANCE_COUNT; i++) {
IMap map = instances[i].getMap(mapName);
assertEquals(format("Each member should own %d entries of the map", entriesPerPartition), entriesPerPartition, map.getLocalMapStats().getOwnedEntryCount());
totalBackups += map.getLocalMapStats().getBackupEntryCount();
}
assertEquals(format("Expected to find %d backups in the cluster", expectedEntryCount), expectedEntryCount, totalBackups);
}
});
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class TimedMemberStateTest method testReplicatedMapGetStats.
@Test
public void testReplicatedMapGetStats() {
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
hz.getReplicatedMap("replicatedMap");
ReplicatedMapService replicatedMapService = nodeEngine.getService(ReplicatedMapService.SERVICE_NAME);
assertNotNull(replicatedMapService.getStats().get("replicatedMap"));
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class OperationFailureTest method onFailure_shouldBeCalled_whenOperationIsRejected.
@Test
public void onFailure_shouldBeCalled_whenOperationIsRejected() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz = factory.newHazelcastInstance();
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
FailingOperation op = new FailingOperation(new CountDownLatch(1));
op.setPartitionId(1).setReplicaIndex(1);
nodeEngine.getOperationService().execute(op);
assertOpenEventually(op.latch);
assertInstanceOf(WrongTargetException.class, op.failure);
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class ServiceManagerImplTest method setup.
@Before
public void setup() {
Config config = new Config();
ServiceConfig serviceConfig = new ServiceConfig().setClassName(FooService.class.getName()).setEnabled(true).setName("fooService");
config.getServicesConfig().addServiceConfig(serviceConfig);
HazelcastInstance hz = createHazelcastInstance(config);
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
serviceManager = (ServiceManagerImpl) nodeEngine.getServiceManager();
}
Aggregations