Search in sources :

Example 31 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class MultiMapProxyImpl method tryLock.

@Override
public boolean tryLock(@Nonnull K key, long time, TimeUnit timeunit) throws InterruptedException {
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    NodeEngine nodeEngine = getNodeEngine();
    Data dataKey = nodeEngine.toData(key);
    return lockSupport.tryLock(nodeEngine, dataKey, time, timeunit);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Data(com.hazelcast.internal.serialization.Data)

Example 32 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class MultiMapProxyImpl method containsEntry.

@Override
public boolean containsEntry(@Nonnull K key, @Nonnull V value) {
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    checkNotNull(value, NULL_VALUE_IS_NOT_ALLOWED);
    NodeEngine nodeEngine = getNodeEngine();
    Data dataKey = nodeEngine.toData(key);
    Data valueKey = nodeEngine.toData(value);
    return containsInternal(dataKey, valueKey);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Data(com.hazelcast.internal.serialization.Data)

Example 33 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class ScheduledExecutorServiceProxy method shutdown.

@Override
public void shutdown() {
    NodeEngine nodeEngine = getNodeEngine();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Future> calls = new LinkedList<>();
    for (Member member : members) {
        Operation op = new ShutdownOperation(name);
        calls.add(operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress()));
    }
    waitWithDeadline(calls, SHUTDOWN_TIMEOUT, TimeUnit.SECONDS, shutdownExceptionHandler);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Future(java.util.concurrent.Future) IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) GetAllScheduledOnMemberOperation(com.hazelcast.scheduledexecutor.impl.operations.GetAllScheduledOnMemberOperation) ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) Member(com.hazelcast.cluster.Member) LinkedList(java.util.LinkedList)

Example 34 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class SqlServiceImpl method createOptimizer.

/**
 * Create either normal or not-implemented optimizer instance.
 *
 * @param nodeEngine Node engine.
 * @return Optimizer.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private SqlOptimizer createOptimizer(NodeEngine nodeEngine, QueryResultRegistry resultRegistry) {
    // 1. Resolve class name.
    String className = System.getProperty(OPTIMIZER_CLASS_PROPERTY_NAME, SQL_MODULE_OPTIMIZER_CLASS);
    // 2. Get the class.
    Class clazz;
    try {
        clazz = Class.forName(className);
    } catch (ClassNotFoundException e) {
        logger.log(SQL_MODULE_OPTIMIZER_CLASS.equals(className) ? Level.FINE : Level.WARNING, "Optimizer class \"" + className + "\" not found, falling back to " + DisabledSqlOptimizer.class.getName());
        return new DisabledSqlOptimizer();
    } catch (Exception e) {
        throw new HazelcastException("Failed to resolve optimizer class " + className + ": " + e.getMessage(), e);
    }
    // 3. Get required constructor.
    Constructor<SqlOptimizer> constructor;
    try {
        constructor = clazz.getConstructor(NodeEngine.class, QueryResultRegistry.class);
    } catch (ReflectiveOperationException e) {
        throw new HazelcastException("Failed to get the constructor for the optimizer class " + className + ": " + e.getMessage(), e);
    }
    // 4. Finally, get the instance.
    try {
        return constructor.newInstance(nodeEngine, resultRegistry);
    } catch (ReflectiveOperationException e) {
        throw new HazelcastException("Failed to instantiate the optimizer class " + className + ": " + e.getMessage(), e);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastException(com.hazelcast.core.HazelcastException) QueryResultRegistry(com.hazelcast.sql.impl.state.QueryResultRegistry) DisabledSqlOptimizer(com.hazelcast.sql.impl.optimizer.DisabledSqlOptimizer) DisabledSqlOptimizer(com.hazelcast.sql.impl.optimizer.DisabledSqlOptimizer) SqlOptimizer(com.hazelcast.sql.impl.optimizer.SqlOptimizer) HazelcastException(com.hazelcast.core.HazelcastException) AccessControlException(java.security.AccessControlException)

Example 35 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class PutRemoteTransactionBackupOperation method run.

@Override
public void run() throws Exception {
    XAService xaService = getService();
    NodeEngine nodeEngine = getNodeEngine();
    XATransaction transaction = new XATransaction(nodeEngine, records, txnId, xid, txOwnerUuid, timeoutMillis, startTime);
    xaService.putTransaction(transaction);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) XAService(com.hazelcast.transaction.impl.xa.XAService) XATransaction(com.hazelcast.transaction.impl.xa.XATransaction)

Aggregations

NodeEngine (com.hazelcast.spi.impl.NodeEngine)165 Data (com.hazelcast.internal.serialization.Data)48 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)30 Address (com.hazelcast.cluster.Address)22 Test (org.junit.Test)21 ILogger (com.hazelcast.logging.ILogger)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)18 QuickTest (com.hazelcast.test.annotation.QuickTest)18 Config (com.hazelcast.config.Config)17 Operation (com.hazelcast.spi.impl.operationservice.Operation)16 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)15 IPartitionService (com.hazelcast.internal.partition.IPartitionService)12 Nonnull (javax.annotation.Nonnull)12 ArrayList (java.util.ArrayList)11 Future (java.util.concurrent.Future)11 Member (com.hazelcast.cluster.Member)10 UUID (java.util.UUID)10 InitializingObject (com.hazelcast.spi.impl.InitializingObject)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9