Search in sources :

Example 1 with JetClientInstanceImpl

use of com.hazelcast.jet.impl.JetClientInstanceImpl in project hazelcast by hazelcast.

the class SqlMetadataInJobConfigTest method test_selectMetadata_clientJobSummary.

@Test
public void test_selectMetadata_clientJobSummary() {
    String sql = "SELECT * FROM table(generate_stream(1))";
    try (SqlResult ignored = client().getSql().execute(new SqlStatement(sql).setCursorBufferSize(1))) {
        List<JobSummary> jobSummaries = ((JetClientInstanceImpl) client().getJet()).getJobSummaryList().stream().filter(jobSummary -> jobSummary.getStatus() == RUNNING).collect(Collectors.toList());
        assertEquals(1, jobSummaries.size());
        JobSummary jobSummary = jobSummaries.get(0);
    // TODO uncomment this when doing https://github.com/hazelcast/hazelcast/issues/20372
    // assertNotNull(jobSummary.getSqlSummary());
    // assertEquals(sql, jobSummary.getSqlSummary().getQuery());
    // assertEquals(Boolean.TRUE, jobSummary.getSqlSummary().isUnbounded());
    }
}
Also used : JobSummary(com.hazelcast.jet.impl.JobSummary) JobSummary(com.hazelcast.jet.impl.JobSummary) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) BeforeClass(org.junit.BeforeClass) QuickTest(com.hazelcast.test.annotation.QuickTest) JobConfig(com.hazelcast.jet.config.JobConfig) SqlStatement(com.hazelcast.sql.SqlStatement) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) TestBatchSqlConnector(com.hazelcast.jet.sql.impl.connector.test.TestBatchSqlConnector) Collectors(java.util.stream.Collectors) List(java.util.List) Future(java.util.concurrent.Future) Ignore(org.junit.Ignore) KEY_SQL_UNBOUNDED(com.hazelcast.jet.config.JobConfigArguments.KEY_SQL_UNBOUNDED) SqlResult(com.hazelcast.sql.SqlResult) RUNNING(com.hazelcast.jet.core.JobStatus.RUNNING) JetClientInstanceImpl(com.hazelcast.jet.impl.JetClientInstanceImpl) JobStatus(com.hazelcast.jet.core.JobStatus) COMPLETED(com.hazelcast.jet.core.JobStatus.COMPLETED) KEY_SQL_QUERY_TEXT(com.hazelcast.jet.config.JobConfigArguments.KEY_SQL_QUERY_TEXT) Assert.assertEquals(org.junit.Assert.assertEquals) Job(com.hazelcast.jet.Job) SqlStatement(com.hazelcast.sql.SqlStatement) SqlResult(com.hazelcast.sql.SqlResult) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with JetClientInstanceImpl

use of com.hazelcast.jet.impl.JetClientInstanceImpl in project hazelcast by hazelcast.

the class NonSmartClientTest method when_jobSummaryListIsAsked_then_jobSummaryListReturned.

@Test
public void when_jobSummaryListIsAsked_then_jobSummaryListReturned() {
    // Given
    Job job = startJobAndVerifyItIsRunning();
    // When
    List<JobSummary> summaryList = ((JetClientInstanceImpl) nonMasterClient.getJet()).getJobSummaryList();
    // Then
    assertNotNull(summaryList);
    assertTrue(summaryList.stream().anyMatch(s -> s.getJobId() == job.getId()));
}
Also used : JobSummary(com.hazelcast.jet.impl.JobSummary) JobSummary(com.hazelcast.jet.impl.JobSummary) Address(com.hazelcast.cluster.Address) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) BeforeClass(org.junit.BeforeClass) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) JetService(com.hazelcast.jet.JetService) ClientConfig(com.hazelcast.client.config.ClientConfig) Assert.fail(org.junit.Assert.fail) DAG(com.hazelcast.jet.core.DAG) JetClientInstanceImpl(com.hazelcast.jet.impl.JetClientInstanceImpl) JobStatus(com.hazelcast.jet.core.JobStatus) Job(com.hazelcast.jet.Job) SimpleTestInClusterSupport(com.hazelcast.jet.SimpleTestInClusterSupport) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Pipeline(com.hazelcast.jet.pipeline.Pipeline) CancellationException(java.util.concurrent.CancellationException) Assert.assertNotNull(org.junit.Assert.assertNotNull) JobConfig(com.hazelcast.jet.config.JobConfig) Sinks(com.hazelcast.jet.pipeline.Sinks) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) Sources(com.hazelcast.jet.pipeline.Sources) List(java.util.List) TestProcessors.streamingDag(com.hazelcast.jet.core.TestProcessors.streamingDag) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertEquals(org.junit.Assert.assertEquals) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend) JetClientInstanceImpl(com.hazelcast.jet.impl.JetClientInstanceImpl) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with JetClientInstanceImpl

use of com.hazelcast.jet.impl.JetClientInstanceImpl in project hazelcast by hazelcast.

the class HazelcastCommandLine method listJobs.

@Command(name = "list-jobs", description = "Lists running jobs on the cluster")
public void listJobs(@Mixin(name = "verbosity") Verbosity verbosity, @Mixin(name = "targets") TargetsMixin targets, @Option(names = { "-a", "--all" }, description = "Lists all jobs including completed and failed ones") boolean listAll) {
    runWithHazelcast(targets, verbosity, false, hz -> {
        JetClientInstanceImpl jetClientInstanceImpl = (JetClientInstanceImpl) hz.getJet();
        List<JobSummary> summaries = jetClientInstanceImpl.getJobSummaryList();
        String format = "%-19s %-18s %-23s %s";
        printf(format, "ID", "STATUS", "SUBMISSION TIME", "NAME");
        summaries.stream().filter(job -> listAll || isActive(job.getStatus())).forEach(job -> {
            String idString = idToString(job.getJobId());
            String name = job.getName().equals(idString) ? "N/A" : job.getName();
            printf(format, idString, job.getStatus(), toLocalDateTime(job.getSubmissionTime()), name);
        });
    });
}
Also used : JobSummary(com.hazelcast.jet.impl.JobSummary) Arrays(java.util.Arrays) BuildInfoProvider.getBuildInfo(com.hazelcast.instance.BuildInfoProvider.getBuildInfo) Parameters(picocli.CommandLine.Parameters) Member(com.hazelcast.cluster.Member) LogManager(java.util.logging.LogManager) ITypeConverter(picocli.CommandLine.ITypeConverter) JetClientInstanceImpl(com.hazelcast.jet.impl.JetClientInstanceImpl) HazelcastVersionProvider(com.hazelcast.client.console.HazelcastCommandLine.HazelcastVersionProvider) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) JobStatus(com.hazelcast.jet.core.JobStatus) CommandLine(picocli.CommandLine) XmlClientConfigBuilder(com.hazelcast.client.config.XmlClientConfigBuilder) MCClusterMetadata(com.hazelcast.client.impl.management.MCClusterMetadata) YamlClientConfigBuilder(com.hazelcast.client.config.YamlClientConfigBuilder) Collections.emptyList(java.util.Collections.emptyList) Mixin(picocli.CommandLine.Mixin) Collection(java.util.Collection) ExecutionException(picocli.CommandLine.ExecutionException) ConsumerEx(com.hazelcast.function.ConsumerEx) ClientClusterService(com.hazelcast.client.impl.spi.ClientClusterService) InvocationTargetException(java.lang.reflect.InvocationTargetException) LockSupport(java.util.concurrent.locks.LockSupport) Option(picocli.CommandLine.Option) List(java.util.List) Util.idToString(com.hazelcast.jet.Util.idToString) JobStateSnapshot(com.hazelcast.jet.JobStateSnapshot) Util.toLocalDateTime(com.hazelcast.jet.impl.util.Util.toLocalDateTime) Util.uncheckCall(com.hazelcast.jet.impl.util.Util.uncheckCall) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) RunAll(picocli.CommandLine.RunAll) JobSummary(com.hazelcast.jet.impl.JobSummary) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) FutureUtil(com.hazelcast.internal.util.FutureUtil) HelpCommand(picocli.CommandLine.HelpCommand) HazelcastClient(com.hazelcast.client.HazelcastClient) LocalDateTime(java.time.LocalDateTime) CompletableFuture(java.util.concurrent.CompletableFuture) MCGetClusterMetadataCodec(com.hazelcast.client.impl.protocol.codec.MCGetClusterMetadataCodec) Function(java.util.function.Function) Level(java.util.logging.Level) JetException(com.hazelcast.jet.JetException) HazelcastBootstrap(com.hazelcast.instance.impl.HazelcastBootstrap) DefaultExceptionHandler(picocli.CommandLine.DefaultExceptionHandler) ClientConfig(com.hazelcast.client.config.ClientConfig) BuildInfo(com.hazelcast.instance.BuildInfo) ParseResult(picocli.CommandLine.ParseResult) Command(picocli.CommandLine.Command) Job(com.hazelcast.jet.Job) JobNotFoundException(com.hazelcast.jet.core.JobNotFoundException) PrintStream(java.io.PrintStream) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Cluster(com.hazelcast.cluster.Cluster) Ansi(picocli.CommandLine.Help.Ansi) IOException(java.io.IOException) Preconditions.checkNotNull(com.hazelcast.internal.util.Preconditions.checkNotNull) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClusterState(com.hazelcast.cluster.ClusterState) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) IVersionProvider(picocli.CommandLine.IVersionProvider) Comparator(java.util.Comparator) Collections(java.util.Collections) Util(com.hazelcast.jet.Util) SECONDS(java.util.concurrent.TimeUnit.SECONDS) JetClientInstanceImpl(com.hazelcast.jet.impl.JetClientInstanceImpl) Util.idToString(com.hazelcast.jet.Util.idToString) HelpCommand(picocli.CommandLine.HelpCommand) Command(picocli.CommandLine.Command)

Example 4 with JetClientInstanceImpl

use of com.hazelcast.jet.impl.JetClientInstanceImpl in project hazelcast by hazelcast.

the class JetTest method when_jetDisabled_and_usingClient_then_getSummaryListThrowsException.

@Test
public void when_jetDisabled_and_usingClient_then_getSummaryListThrowsException() {
    Config config = smallInstanceConfig();
    config.getJetConfig().setEnabled(false);
    createHazelcastInstance(config);
    HazelcastInstance client = createHazelcastClient();
    JetClientInstanceImpl jet = (JetClientInstanceImpl) client.getJet();
    assertThrows(JetDisabledException.class, jet::getJobSummaryList);
}
Also used : JetClientInstanceImpl(com.hazelcast.jet.impl.JetClientInstanceImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) JobConfig(com.hazelcast.jet.config.JobConfig) MapConfig(com.hazelcast.config.MapConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

JetClientInstanceImpl (com.hazelcast.jet.impl.JetClientInstanceImpl)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 Job (com.hazelcast.jet.Job)3 JobConfig (com.hazelcast.jet.config.JobConfig)3 JobStatus (com.hazelcast.jet.core.JobStatus)3 JobSummary (com.hazelcast.jet.impl.JobSummary)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2 List (java.util.List)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 BeforeClass (org.junit.BeforeClass)2 Test (org.junit.Test)2 Category (org.junit.experimental.categories.Category)2 HazelcastClient (com.hazelcast.client.HazelcastClient)1 XmlClientConfigBuilder (com.hazelcast.client.config.XmlClientConfigBuilder)1 YamlClientConfigBuilder (com.hazelcast.client.config.YamlClientConfigBuilder)1 HazelcastVersionProvider (com.hazelcast.client.console.HazelcastCommandLine.HazelcastVersionProvider)1 ClientDelegatingFuture (com.hazelcast.client.impl.ClientDelegatingFuture)1 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)1