Search in sources :

Example 1 with NodeEngine

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

the class PlanExecutor method execute.

SqlResult execute(ShowStatementPlan plan) {
    Stream<String> rows;
    switch(plan.getShowTarget()) {
        case MAPPINGS:
            rows = catalog.getMappingNames().stream();
            break;
        case VIEWS:
            rows = catalog.getViewNames().stream();
            break;
        case JOBS:
            assert plan.getShowTarget() == ShowStatementTarget.JOBS;
            NodeEngine nodeEngine = getNodeEngine(hazelcastInstance);
            JetServiceBackend jetServiceBackend = nodeEngine.getService(JetServiceBackend.SERVICE_NAME);
            rows = jetServiceBackend.getJobRepository().getJobRecords().stream().map(record -> record.getConfig().getName()).filter(Objects::nonNull);
            break;
        default:
            throw new AssertionError("Unsupported SHOW statement target.");
    }
    SqlRowMetadata metadata = new SqlRowMetadata(singletonList(new SqlColumnMetadata("name", VARCHAR, false)));
    InternalSerializationService serializationService = Util.getSerializationService(hazelcastInstance);
    return new SqlResultImpl(QueryId.create(hazelcastInstance.getLocalEndpoint().getUuid()), new StaticQueryResultProducerImpl(rows.sorted().map(name -> new JetSqlRow(serializationService, new Object[] { name })).iterator()), metadata, false);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Util.getNodeEngine(com.hazelcast.jet.impl.util.Util.getNodeEngine) UpdateSqlResultImpl(com.hazelcast.sql.impl.UpdateSqlResultImpl) Arrays(java.util.Arrays) DropViewPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DropViewPlan) SelectPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.SelectPlan) TimeoutException(java.util.concurrent.TimeoutException) Extractors(com.hazelcast.query.impl.getters.Extractors) SQL_ARGUMENTS_KEY_NAME(com.hazelcast.sql.impl.expression.ExpressionEvalContext.SQL_ARGUMENTS_KEY_NAME) CreateIndexPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateIndexPlan) SqlRowMetadata(com.hazelcast.sql.SqlRowMetadata) QueryParameterMetadata(com.hazelcast.sql.impl.QueryParameterMetadata) Collections.singletonList(java.util.Collections.singletonList) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) ParameterConverter(com.hazelcast.sql.impl.ParameterConverter) SqlNode(org.apache.calcite.sql.SqlNode) Map(java.util.Map) VARCHAR(com.hazelcast.sql.SqlColumnType.VARCHAR) CreateJobPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateJobPlan) CreateMappingPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateMappingPlan) DropMappingPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DropMappingPlan) CancellationException(java.util.concurrent.CancellationException) JobConfig(com.hazelcast.jet.config.JobConfig) AlterJobPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.AlterJobPlan) QueryResultRegistry(com.hazelcast.sql.impl.state.QueryResultRegistry) IMapUpdatePlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapUpdatePlan) IndexConfig(com.hazelcast.config.IndexConfig) IMapSelectPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapSelectPlan) Objects(java.util.Objects) Util(com.hazelcast.jet.impl.util.Util) List(java.util.List) ExpressionEvalContext(com.hazelcast.sql.impl.expression.ExpressionEvalContext) Stream(java.util.stream.Stream) JobStateSnapshot(com.hazelcast.jet.JobStateSnapshot) EmptyRow(com.hazelcast.sql.impl.row.EmptyRow) DropJobPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DropJobPlan) DmlPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DmlPlan) RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) UNIQUE_KEY_TRANSFORMATION(com.hazelcast.jet.sql.impl.parse.SqlCreateIndex.UNIQUE_KEY_TRANSFORMATION) SqlResult(com.hazelcast.sql.SqlResult) Entry(java.util.Map.Entry) SqlErrorCode(com.hazelcast.sql.impl.SqlErrorCode) UniqueKeyTransformation(com.hazelcast.config.BitmapIndexOptions.UniqueKeyTransformation) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) SqlColumnMetadata(com.hazelcast.sql.SqlColumnMetadata) IMapSinkPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapSinkPlan) EntryRemovingProcessor(com.hazelcast.map.impl.EntryRemovingProcessor) ArrayList(java.util.ArrayList) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) IndexType(com.hazelcast.config.IndexType) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) IMapInsertPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapInsertPlan) View(com.hazelcast.sql.impl.schema.view.View) IMapDeletePlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapDeletePlan) KEY_SQL_QUERY_TEXT(com.hazelcast.jet.config.JobConfigArguments.KEY_SQL_QUERY_TEXT) Job(com.hazelcast.jet.Job) QueryException(com.hazelcast.sql.impl.QueryException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) NodeEngine(com.hazelcast.spi.impl.NodeEngine) MapContainer(com.hazelcast.map.impl.MapContainer) CreateViewPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateViewPlan) DropSnapshotPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DropSnapshotPlan) TableResolverImpl(com.hazelcast.jet.sql.impl.schema.TableResolverImpl) MapService(com.hazelcast.map.impl.MapService) QueryId(com.hazelcast.sql.impl.QueryId) RelNode(org.apache.calcite.rel.RelNode) BitmapIndexOptions(com.hazelcast.config.BitmapIndexOptions) ShowStatementTarget(com.hazelcast.jet.sql.impl.parse.SqlShowStatement.ShowStatementTarget) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) HazelcastTypeUtils.toHazelcastType(com.hazelcast.jet.sql.impl.validate.types.HazelcastTypeUtils.toHazelcastType) CreateSnapshotPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateSnapshotPlan) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) ShowStatementPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.ShowStatementPlan) UNIQUE_KEY(com.hazelcast.jet.sql.impl.parse.SqlCreateIndex.UNIQUE_KEY) ExplainStatementPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.ExplainStatementPlan) Util.getNodeEngine(com.hazelcast.jet.impl.util.Util.getNodeEngine) KEY_SQL_UNBOUNDED(com.hazelcast.jet.config.JobConfigArguments.KEY_SQL_UNBOUNDED) AbstractJetInstance(com.hazelcast.jet.impl.AbstractJetInstance) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend) IMap(com.hazelcast.map.IMap) SqlRowMetadata(com.hazelcast.sql.SqlRowMetadata) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) UpdateSqlResultImpl(com.hazelcast.sql.impl.UpdateSqlResultImpl) SqlColumnMetadata(com.hazelcast.sql.SqlColumnMetadata) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend)

Example 2 with NodeEngine

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

the class CacheDestroyOperation method destroyCacheOnAllMembers.

private void destroyCacheOnAllMembers(String name, UUID callerUuid) {
    NodeEngine nodeEngine = getNodeEngine();
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    for (Member member : members) {
        if (!member.localMember() && !member.getUuid().equals(callerUuid)) {
            CacheDestroyOperation op = new CacheDestroyOperation(name, true);
            operationService.invokeOnTarget(ICacheService.SERVICE_NAME, op, member.getAddress());
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Member(com.hazelcast.cluster.Member)

Example 3 with NodeEngine

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

the class MapFlushMessageTask method call.

@Override
protected Object call() throws Exception {
    MapService mapService = getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    ProxyService proxyService = nodeEngine.getProxyService();
    UUID source = endpoint.getUuid();
    DistributedObject distributedObject = proxyService.getDistributedObject(SERVICE_NAME, parameters, source);
    MapProxyImpl mapProxy = (MapProxyImpl) distributedObject;
    mapProxy.flush();
    return null;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) DistributedObject(com.hazelcast.core.DistributedObject) ProxyService(com.hazelcast.spi.impl.proxyservice.ProxyService) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService) UUID(java.util.UUID) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 4 with NodeEngine

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

the class AbstractCollectionProxyImpl method compareAndRemove.

private boolean compareAndRemove(boolean retain, @Nonnull Collection<?> c) {
    checkNotNull(c, "Null collection is not allowed");
    Set<Data> valueSet = createHashSet(c.size());
    final NodeEngine nodeEngine = getNodeEngine();
    for (Object o : c) {
        checkNotNull(o, "Null collection element is not allowed");
        valueSet.add(nodeEngine.toData(o));
    }
    final CollectionCompareAndRemoveOperation operation = new CollectionCompareAndRemoveOperation(name, retain, valueSet);
    final Boolean result = invoke(operation);
    return result;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Data(com.hazelcast.internal.serialization.Data) AbstractDistributedObject(com.hazelcast.spi.impl.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.impl.InitializingObject) CollectionCompareAndRemoveOperation(com.hazelcast.collection.impl.collection.operations.CollectionCompareAndRemoveOperation)

Example 5 with NodeEngine

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

the class AbstractCollectionProxyImpl method containsAll.

public boolean containsAll(@Nonnull Collection<?> c) {
    checkNotNull(c, "Null collection is not allowed");
    Set<Data> valueSet = createHashSet(c.size());
    final NodeEngine nodeEngine = getNodeEngine();
    for (Object o : c) {
        checkNotNull(o, "Null collection element is not allowed");
        valueSet.add(nodeEngine.toData(o));
    }
    final CollectionContainsOperation operation = new CollectionContainsOperation(name, valueSet);
    final Boolean result = invoke(operation);
    return result;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Data(com.hazelcast.internal.serialization.Data) AbstractDistributedObject(com.hazelcast.spi.impl.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.impl.InitializingObject) CollectionContainsOperation(com.hazelcast.collection.impl.collection.operations.CollectionContainsOperation)

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