use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class PartitionReplicaSyncResponse method nodeNotOwnsBackup.
/**
* Fail all replication operations with the exception that this node is no longer the replica with the sent index
*/
private void nodeNotOwnsBackup(InternalPartitionImpl partition) {
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
NodeEngine nodeEngine = getNodeEngine();
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
int currentReplicaIndex = partition.getReplicaIndex(PartitionReplica.from(nodeEngine.getLocalMember()));
logger.finest("This node is not backup replica of partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + " anymore. current replicaIndex=" + currentReplicaIndex);
}
if (operations != null) {
PartitionReplica replica = partition.getReplica(replicaIndex);
Member targetMember = null;
if (replica != null) {
ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
targetMember = clusterService.getMember(replica.address(), replica.uuid());
}
Throwable throwable = new WrongTargetException(nodeEngine.getLocalMember(), targetMember, partitionId, replicaIndex, getClass().getName());
for (Operation op : operations) {
prepareOperation(op);
onOperationFailure(op, throwable);
}
}
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class PartitionReplicaSyncRequest method sendResponse.
/**
* Send a synchronization response to the caller replica containing the replication operations to be executed
*/
private void sendResponse(Collection<Operation> operations, Collection<ChunkSupplier> chunkSuppliers, ServiceNamespace ns) {
NodeEngine nodeEngine = getNodeEngine();
PartitionReplicaSyncResponse syncResponse = createResponse(operations, chunkSuppliers, ns);
Address target = getCallerAddress();
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
logger.finest("Sending sync response to -> " + target + " for partitionId=" + partitionId() + ", replicaIndex=" + getReplicaIndex() + ", namespaces=" + ns);
}
// PartitionReplicaSyncResponse is TargetAware and sent directly without invocation system.
syncResponse.setTarget(target);
OperationService operationService = nodeEngine.getOperationService();
operationService.send(syncResponse, target);
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class BasicMapStoreContext method create.
static MapStoreContext create(MapContainer mapContainer) {
final BasicMapStoreContext context = new BasicMapStoreContext();
final String mapName = mapContainer.getName();
final MapServiceContext mapServiceContext = mapContainer.getMapServiceContext();
final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
final PartitioningStrategy partitioningStrategy = mapContainer.getPartitioningStrategy();
final MapConfig mapConfig = mapContainer.getMapConfig();
final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
final ClassLoader configClassLoader = nodeEngine.getConfigClassLoader();
// create store.
final Object store = createStore(mapName, mapStoreConfig, configClassLoader);
final MapStoreWrapper storeWrapper = new MapStoreWrapper(mapName, store);
storeWrapper.instrument(nodeEngine);
context.setMapName(mapName);
context.setMapStoreConfig(mapStoreConfig);
context.setPartitioningStrategy(partitioningStrategy);
context.setMapServiceContext(mapServiceContext);
context.setStoreWrapper(storeWrapper);
final MapStoreManager mapStoreManager = createMapStoreManager(context);
context.setMapStoreManager(mapStoreManager);
// todo this is user code. it may also block map store creation.
callLifecycleSupportInit(context);
return context;
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class BasicMapStoreContext method callLifecycleSupportInit.
private static void callLifecycleSupportInit(MapStoreContext mapStoreContext) {
final MapStoreWrapper mapStoreWrapper = mapStoreContext.getMapStoreWrapper();
final MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext();
final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
final HazelcastInstance hazelcastInstance = nodeEngine.getHazelcastInstance();
final MapStoreConfig mapStoreConfig = mapStoreContext.getMapStoreConfig();
final Properties properties = mapStoreConfig.getProperties();
final String mapName = mapStoreContext.getMapName();
mapStoreWrapper.init(hazelcastInstance, properties, mapName);
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class WriteBehindStore method getInMemoryFormat.
private static InMemoryFormat getInMemoryFormat(MapStoreContext mapStoreContext) {
MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext();
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
Config config = nodeEngine.getConfig();
String mapName = mapStoreContext.getMapName();
MapConfig mapConfig = config.findMapConfig(mapName);
return mapConfig.getInMemoryFormat();
}
Aggregations