CassandraDaemonTask extends CassandraTask { private static CassandraConfig updateConfig( final CassandraMode mode, final CassandraConfig config) { if (CassandraMode.NORMAL.equals(mode)) { return config.mutable().setReplaceIp("").build(); } else { return config; } } private  CassandraDaemonTask(
        final String name,
        final String configName,
        final CassandraTaskExecutor executor,
        final CassandraConfig config,
        final Capabilities capabilities,
        final CassandraData data); private  CassandraDaemonTask(
            final String name,
            final String configName,
            final CassandraTaskExecutor executor,
            final CassandraConfig config,
            final Capabilities capabilities); private  CassandraDaemonTask(final Protos.TaskInfo info); static CassandraDaemonTask parse(final Protos.TaskInfo info); CassandraConfig getConfig(); CassandraMode getMode(); @Override CassandraDaemonTask update(CassandraTaskStatus status); @Override CassandraDaemonTask update(Protos.TaskState state); CassandraDaemonStatus createStatus(Protos.TaskState state,
                                              CassandraMode mode,
                                              Optional<String> message); String getVolumePath(); @Override CassandraDaemonStatus createStatus(Protos.TaskState state,
                                              Optional<String> message); @Override CassandraDaemonTask update(Protos.Offer offer); CassandraDaemonTask updateConfig(CassandraConfig cassandraConfig,
                                            ExecutorConfig executorConfig,
                                            UUID targetConfigName); @Override CassandraDaemonTask updateId(); static final String NAME_PREFIX; static final String VIP_NODE_NAME; static final int VIP_NODE_PORT; }
@Test public void testUpdateUnchangedConfig() { CassandraDaemonTask daemonTask = testTaskFactory.create( TEST_DAEMON_NAME, TEST_CONFIG_NAME, testTaskExecutor, CassandraConfig.DEFAULT); CassandraDaemonTask updatedTask = daemonTask.updateConfig( CassandraConfig.DEFAULT, testExecutorConfig, TEST_CONFIG_ID); Assert.assertEquals(normalizeCassandraTaskInfo(daemonTask), normalizeCassandraTaskInfo(updatedTask)); }
@Test public void testUpdateCassandraLocation() throws URISyntaxException { CassandraDaemonTask daemonTask = testTaskFactory.create( TEST_DAEMON_NAME, TEST_CONFIG_NAME, testTaskExecutor, CassandraConfig.DEFAULT); ExecutorConfig updatedTestExecutorConfig = ExecutorConfig.create( "test-cmd", Arrays.asList("arg0"), 1.0, 256, 500, 1000, "java-home", new URI("http: new URI("http: new URI("http: new URI("http: false); testTaskExecutor = CassandraTaskExecutor.create( "test-framework-id", TEST_DAEMON_NAME, "test-role", "test-principal", updatedTestExecutorConfig); CassandraDaemonTask updatedTask = daemonTask.updateConfig( CassandraConfig.DEFAULT, updatedTestExecutorConfig, TEST_CONFIG_ID); Assert.assertNotEquals(normalizeCassandraTaskInfo(daemonTask), normalizeCassandraTaskInfo(updatedTask)); Assert.assertEquals(4, updatedTask.getExecutor().getURIs().size()); Assert.assertTrue(updatedTask.getExecutor().getURIs().contains("http: }
@Test public void testUpdateCacheFetchedUris() throws URISyntaxException { CassandraDaemonTask daemonTask = testTaskFactory.create( TEST_DAEMON_NAME, TEST_CONFIG_NAME, testTaskExecutor, CassandraConfig.DEFAULT); ExecutorConfig updatedTestExecutorConfig = ExecutorConfig.create( "test-cmd", Arrays.asList("arg0"), 1.0, 256, 500, 1000, "java-home", new URI("http: new URI("http: new URI("http: new URI("http: true); testTaskExecutor = CassandraTaskExecutor.create( "test-framework-id", TEST_DAEMON_NAME, "test-role", "test-principal", updatedTestExecutorConfig); CassandraDaemonTask updatedTask = daemonTask.updateConfig( CassandraConfig.DEFAULT, updatedTestExecutorConfig, TEST_CONFIG_ID); Assert.assertTrue(allUrisAreCacheable(updatedTask.getTaskInfo().getExecutor().getCommand().getUrisList(), true)); }
@Test public void testUpdateLibmesosLocation() throws URISyntaxException, UnsupportedEncodingException { final String DEFAULT_LIBMESOS_LOCATION = "http: ENV_VARS.set("EXECUTOR_LIBMESOS_LOCATION", DEFAULT_LIBMESOS_LOCATION); ExecutorConfig testExecutorConfig = ExecutorConfig.create( "test-cmd", Arrays.asList("arg0"), 1.0, 256, 500, 1000, "java-home", "http: "http: "http: null, false, false); testTaskExecutor = CassandraTaskExecutor.create( "test-framework-id", TEST_DAEMON_NAME, "test-role", "test-principal", testExecutorConfig); CassandraDaemonTask daemonTask = testTaskFactory.create( TEST_DAEMON_NAME, TEST_CONFIG_NAME, testTaskExecutor, CassandraConfig.DEFAULT); Assert.assertEquals(4, daemonTask.getExecutor().getURIs().size()); Assert.assertTrue(daemonTask.getExecutor().getURIs().contains(DEFAULT_LIBMESOS_LOCATION)); ExecutorConfig updatedTestExecutorConfig = ExecutorConfig.create( "test-cmd", Arrays.asList("arg0"), 1.0, 256, 500, 1000, "java-home", "http: "http: "http: "http: false, false); testTaskExecutor = CassandraTaskExecutor.create( "test-framework-id", TEST_DAEMON_NAME, "test-role", "test-principal", updatedTestExecutorConfig); CassandraDaemonTask updatedTask = daemonTask.updateConfig( CassandraConfig.DEFAULT, updatedTestExecutorConfig, TEST_CONFIG_ID); Assert.assertTrue(updatedTask.getExecutor().getURIs().contains("http: }