Search in sources :

Example 1 with TransactionalService

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

the class TransactionContextImpl method getTransactionalObject.

@SuppressWarnings("unchecked")
@Override
public TransactionalObject getTransactionalObject(String serviceName, String name) {
    checkActive(serviceName, name);
    if (requiresBackupLogs(serviceName)) {
        transaction.ensureBackupLogsExist();
    }
    TransactionalObjectKey key = new TransactionalObjectKey(serviceName, name);
    TransactionalObject obj = txnObjectMap.get(key);
    if (obj != null) {
        return obj;
    }
    TransactionalService transactionalService = getTransactionalService(serviceName);
    nodeEngine.getProxyService().initializeDistributedObject(serviceName, name, transaction.getOwnerUuid());
    obj = transactionalService.createTransactionalObject(name, transaction);
    txnObjectMap.put(key, obj);
    return obj;
}
Also used : TransactionalService(com.hazelcast.internal.services.TransactionalService) TransactionalObject(com.hazelcast.transaction.TransactionalObject)

Example 2 with TransactionalService

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

the class AbstractMapServiceFactory method createMapService.

/**
 * Returns a {@link MapService} object by populating it with required
 * auxiliary services.
 *
 * @return {@link MapService} object
 */
@Override
public MapService createMapService() {
    NodeEngine nodeEngine = getNodeEngine();
    MapServiceContext mapServiceContext = getMapServiceContext();
    ManagedService managedService = createManagedService();
    CountingMigrationAwareService migrationAwareService = createMigrationAwareService();
    TransactionalService transactionalService = createTransactionalService();
    RemoteService remoteService = createRemoteService();
    EventPublishingService eventPublishingService = createEventPublishingService();
    PostJoinAwareService postJoinAwareService = createPostJoinAwareService();
    SplitBrainHandlerService splitBrainHandlerService = createSplitBrainHandlerService();
    WanSupportingService wanSupportingService = createReplicationSupportingService();
    StatisticsAwareService statisticsAwareService = createStatisticsAwareService();
    PartitionAwareService partitionAwareService = createPartitionAwareService();
    MapSplitBrainProtectionAwareService splitBrainProtectionAwareService = createSplitBrainProtectionAwareService();
    ClientAwareService clientAwareService = createClientAwareService();
    checkNotNull(nodeEngine, "nodeEngine should not be null");
    checkNotNull(mapServiceContext, "mapServiceContext should not be null");
    checkNotNull(managedService, "managedService should not be null");
    checkNotNull(migrationAwareService, "migrationAwareService should not be null");
    checkNotNull(transactionalService, "transactionalService should not be null");
    checkNotNull(remoteService, "remoteService should not be null");
    checkNotNull(eventPublishingService, "eventPublishingService should not be null");
    checkNotNull(postJoinAwareService, "postJoinAwareService should not be null");
    checkNotNull(splitBrainHandlerService, "splitBrainHandlerService should not be null");
    checkNotNull(wanSupportingService, "replicationSupportingService should not be null");
    checkNotNull(statisticsAwareService, "statisticsAwareService should not be null");
    checkNotNull(partitionAwareService, "partitionAwareService should not be null");
    checkNotNull(splitBrainProtectionAwareService, "splitBrainProtectionAwareService should not be null");
    checkNotNull(clientAwareService, "clientAwareService should not be null");
    MapService mapService = new MapService();
    mapService.managedService = managedService;
    mapService.migrationAwareService = migrationAwareService;
    mapService.transactionalService = transactionalService;
    mapService.remoteService = remoteService;
    mapService.eventPublishingService = eventPublishingService;
    mapService.postJoinAwareService = postJoinAwareService;
    mapService.splitBrainHandlerService = splitBrainHandlerService;
    mapService.wanSupportingService = wanSupportingService;
    mapService.statisticsAwareService = statisticsAwareService;
    mapService.mapServiceContext = mapServiceContext;
    mapService.partitionAwareService = partitionAwareService;
    mapService.splitBrainProtectionAwareService = splitBrainProtectionAwareService;
    mapService.clientAwareService = clientAwareService;
    mapServiceContext.setService(mapService);
    return mapService;
}
Also used : ManagedService(com.hazelcast.internal.services.ManagedService) StatisticsAwareService(com.hazelcast.internal.services.StatisticsAwareService) TransactionalService(com.hazelcast.internal.services.TransactionalService) CountingMigrationAwareService(com.hazelcast.spi.impl.CountingMigrationAwareService) NodeEngine(com.hazelcast.spi.impl.NodeEngine) ClientAwareService(com.hazelcast.internal.services.ClientAwareService) PostJoinAwareService(com.hazelcast.internal.services.PostJoinAwareService) RemoteService(com.hazelcast.internal.services.RemoteService) WanSupportingService(com.hazelcast.internal.services.WanSupportingService) SplitBrainHandlerService(com.hazelcast.internal.services.SplitBrainHandlerService) PartitionAwareService(com.hazelcast.internal.partition.PartitionAwareService) EventPublishingService(com.hazelcast.spi.impl.eventservice.EventPublishingService)

Example 3 with TransactionalService

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

the class XATransactionContextImpl method getTransactionalObject.

@SuppressWarnings("unchecked")
@Override
public TransactionalObject getTransactionalObject(String serviceName, String name) {
    if (transaction.getState() != Transaction.State.ACTIVE) {
        throw new TransactionNotActiveException("No transaction is found while accessing " + "transactional object -> " + serviceName + "[" + name + "]!");
    }
    TransactionalObjectKey key = new TransactionalObjectKey(serviceName, name);
    TransactionalObject obj = txnObjectMap.get(key);
    if (obj != null) {
        return obj;
    }
    final Object service = nodeEngine.getService(serviceName);
    if (service instanceof TransactionalService) {
        nodeEngine.getProxyService().initializeDistributedObject(serviceName, name, transaction.getOwnerUuid());
        obj = ((TransactionalService) service).createTransactionalObject(name, transaction);
        txnObjectMap.put(key, obj);
    } else {
        throw new IllegalArgumentException("Service[" + serviceName + "] is not transactional!");
    }
    return obj;
}
Also used : TransactionalService(com.hazelcast.internal.services.TransactionalService) TransactionNotActiveException(com.hazelcast.transaction.TransactionNotActiveException) TransactionalObject(com.hazelcast.transaction.TransactionalObject) TransactionalObject(com.hazelcast.transaction.TransactionalObject) TransactionalObjectKey(com.hazelcast.transaction.impl.TransactionalObjectKey)

Example 4 with TransactionalService

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

the class BroadcastTxRollbackOperation method run.

@Override
public void run() throws Exception {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Collection<TransactionalService> services = nodeEngine.getServices(TransactionalService.class);
    for (TransactionalService service : services) {
        try {
            service.rollbackTransaction(txnId);
        } catch (Exception e) {
            getLogger().warning("Error while rolling back transaction: " + txnId, e);
        }
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) TransactionalService(com.hazelcast.internal.services.TransactionalService) MemberLeftException(com.hazelcast.core.MemberLeftException) IOException(java.io.IOException)

Aggregations

TransactionalService (com.hazelcast.internal.services.TransactionalService)4 TransactionalObject (com.hazelcast.transaction.TransactionalObject)2 MemberLeftException (com.hazelcast.core.MemberLeftException)1 PartitionAwareService (com.hazelcast.internal.partition.PartitionAwareService)1 ClientAwareService (com.hazelcast.internal.services.ClientAwareService)1 ManagedService (com.hazelcast.internal.services.ManagedService)1 PostJoinAwareService (com.hazelcast.internal.services.PostJoinAwareService)1 RemoteService (com.hazelcast.internal.services.RemoteService)1 SplitBrainHandlerService (com.hazelcast.internal.services.SplitBrainHandlerService)1 StatisticsAwareService (com.hazelcast.internal.services.StatisticsAwareService)1 WanSupportingService (com.hazelcast.internal.services.WanSupportingService)1 CountingMigrationAwareService (com.hazelcast.spi.impl.CountingMigrationAwareService)1 NodeEngine (com.hazelcast.spi.impl.NodeEngine)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 EventPublishingService (com.hazelcast.spi.impl.eventservice.EventPublishingService)1 TransactionNotActiveException (com.hazelcast.transaction.TransactionNotActiveException)1 TransactionalObjectKey (com.hazelcast.transaction.impl.TransactionalObjectKey)1 IOException (java.io.IOException)1