Search in sources :

Example 1 with SplitBrainProtectionAwareService

use of com.hazelcast.internal.services.SplitBrainProtectionAwareService in project hazelcast by hazelcast.

the class SplitBrainProtectionServiceImpl method findSplitBrainProtection.

/**
 * Returns a {@link SplitBrainProtectionImpl} for the given operation. The operation should be named and the
 * operation service should be a {@link SplitBrainProtectionAwareService}. This service will then return the
 * split brain protection configured under the name returned by the operation service.
 *
 * @param op the operation for which the SplitBrainProtection should be returned
 * @return the split brain protection
 */
private SplitBrainProtectionImpl findSplitBrainProtection(Operation op) {
    if (!isNamedOperation(op)) {
        return null;
    }
    SplitBrainProtectionAwareService service = getSplitBrainProtectionAwareService(op);
    if (service == null) {
        return null;
    }
    String name = ((NamedOperation) op).getName();
    String splitBrainProtectionName = service.getSplitBrainProtectionName(name);
    if (splitBrainProtectionName == null) {
        return null;
    }
    return splitBrainProtections.get(splitBrainProtectionName);
}
Also used : SplitBrainProtectionAwareService(com.hazelcast.internal.services.SplitBrainProtectionAwareService) NamedOperation(com.hazelcast.spi.impl.operationservice.NamedOperation)

Example 2 with SplitBrainProtectionAwareService

use of com.hazelcast.internal.services.SplitBrainProtectionAwareService in project hazelcast by hazelcast.

the class SplitBrainProtectionServiceImpl method getSplitBrainProtectionAwareService.

private SplitBrainProtectionAwareService getSplitBrainProtectionAwareService(Operation op) {
    Object service;
    if (op instanceof ServiceNamespaceAware) {
        ServiceNamespace serviceNamespace = ((ServiceNamespaceAware) op).getServiceNamespace();
        service = nodeEngine.getService(serviceNamespace.getServiceName());
    } else {
        service = op.getService();
    }
    if (service instanceof SplitBrainProtectionAwareService) {
        return (SplitBrainProtectionAwareService) service;
    }
    return null;
}
Also used : ServiceNamespaceAware(com.hazelcast.internal.services.ServiceNamespaceAware) SplitBrainProtectionAwareService(com.hazelcast.internal.services.SplitBrainProtectionAwareService) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace)

Aggregations

SplitBrainProtectionAwareService (com.hazelcast.internal.services.SplitBrainProtectionAwareService)2 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)1 ServiceNamespaceAware (com.hazelcast.internal.services.ServiceNamespaceAware)1 NamedOperation (com.hazelcast.spi.impl.operationservice.NamedOperation)1