Search in sources :

Example 1 with ZooKeeperClientProvider

use of com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider in project helios by spotify.

the class JobRemoveTest method testRemoveJobDeletesHistory.

@Test
public void testRemoveJobDeletesHistory() throws Exception {
    startDefaultAgent(testHost());
    awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
    final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, IDLE_COMMAND);
    deployJob(jobId, testHost());
    awaitJobState(defaultClient(), testHost(), jobId, TaskStatus.State.RUNNING, LONG_WAIT_SECONDS, SECONDS);
    undeployJob(jobId, testHost());
    awaitJobUndeployed(defaultClient(), testHost(), jobId, LONG_WAIT_SECONDS, SECONDS);
    final ZooKeeperClient zkClient = new ZooKeeperClientProvider(new DefaultZooKeeperClient(zk().curatorWithSuperAuth()), ZooKeeperModelReporter.noop()).get("test-client");
    // Check that there's some history events
    assertNotNull(zkClient.stat(Paths.historyJob(jobId)));
    // Remove job
    final JobDeleteResponse response = defaultClient().deleteJob(jobId).get(WAIT_TIMEOUT_SECONDS, SECONDS);
    assertEquals(JobDeleteResponse.Status.OK, response.getStatus());
    // Verify that history is gone
    assertNull(zkClient.stat(Paths.historyJob(jobId)));
}
Also used : ZooKeeperClientProvider(com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider) ZooKeeperClient(com.spotify.helios.servicescommon.coordination.ZooKeeperClient) DefaultZooKeeperClient(com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient) DefaultZooKeeperClient(com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient) JobId(com.spotify.helios.common.descriptors.JobId) JobDeleteResponse(com.spotify.helios.common.protocol.JobDeleteResponse) Test(org.junit.Test)

Example 2 with ZooKeeperClientProvider

use of com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider in project helios by spotify.

the class TaskHistoryWriterTest method setUp.

@Before
public void setUp() throws Exception {
    zk = new ZooKeeperTestingServerManager();
    agentStateDirs = Files.createTempDirectory("helios-agents");
    client = new DefaultZooKeeperClient(zk.curatorWithSuperAuth());
    makeWriter(client);
    final ZooKeeperClientProvider zkProvider = new ZooKeeperClientProvider(client, ZooKeeperModelReporter.noop());
    final List<EventSender> eventSenders = Collections.emptyList();
    masterModel = new ZooKeeperMasterModel(zkProvider, "test", eventSenders, TaskStatusEvent.TASK_STATUS_EVENT_TOPIC);
    client.ensurePath(Paths.configJobs());
    client.ensurePath(Paths.configJobRefs());
    client.ensurePath(Paths.historyJobHostEvents(JOB_ID, HOSTNAME));
    masterModel.registerHost(HOSTNAME, "foo");
    masterModel.addJob(JOB);
}
Also used : ZooKeeperClientProvider(com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider) EventSender(com.spotify.helios.servicescommon.EventSender) ZooKeeperTestingServerManager(com.spotify.helios.ZooKeeperTestingServerManager) ZooKeeperMasterModel(com.spotify.helios.master.ZooKeeperMasterModel) DefaultZooKeeperClient(com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient) Before(org.junit.Before)

Example 3 with ZooKeeperClientProvider

use of com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider in project helios by spotify.

the class ZooKeeperMasterModelIntegrationTest method setup.

@Before
public void setup() throws Exception {
    final RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    final CuratorFramework curator = CuratorFrameworkFactory.newClient(zk.connectString(), retryPolicy);
    curator.start();
    final ZooKeeperClient client = new DefaultZooKeeperClient(curator);
    // TODO (dano): this bootstrapping is essentially duplicated from MasterService,
    // should be moved into ZooKeeperMasterModel?
    client.ensurePath(Paths.configHosts());
    client.ensurePath(Paths.configJobs());
    client.ensurePath(Paths.configJobRefs());
    client.ensurePath(Paths.statusHosts());
    client.ensurePath(Paths.statusMasters());
    client.ensurePath(Paths.historyJobs());
    final ZooKeeperClientProvider zkProvider = new ZooKeeperClientProvider(client, ZooKeeperModelReporter.noop());
    final List<EventSender> eventSenders = ImmutableList.of(eventSender);
    model = new ZooKeeperMasterModel(zkProvider, getClass().getName(), eventSenders, deploymentGroupEventTopic);
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) ZooKeeperClientProvider(com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider) ZooKeeperClient(com.spotify.helios.servicescommon.coordination.ZooKeeperClient) DefaultZooKeeperClient(com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) EventSender(com.spotify.helios.servicescommon.EventSender) ZooKeeperMasterModel(com.spotify.helios.master.ZooKeeperMasterModel) DefaultZooKeeperClient(com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient) RetryPolicy(org.apache.curator.RetryPolicy) Before(org.junit.Before)

Example 4 with ZooKeeperClientProvider

use of com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider in project helios by spotify.

the class UndeployFilteringTest method setUp.

@Before
public void setUp() throws Exception {
    // make zookeeper interfaces
    curator = zk().curatorWithSuperAuth();
    final ZooKeeperClientProvider zkcp = new ZooKeeperClientProvider(new DefaultZooKeeperClient(curator), ZooKeeperModelReporter.noop());
    final List<EventSender> eventSenders = Collections.emptyList();
    zkMasterModel = new ZooKeeperMasterModel(zkcp, getClass().getName(), eventSenders, "");
    startDefaultMaster();
    agent = startDefaultAgent(TEST_HOST);
    client = defaultClient();
    awaitHostRegistered(client, TEST_HOST, LONG_WAIT_SECONDS, SECONDS);
}
Also used : ZooKeeperClientProvider(com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider) EventSender(com.spotify.helios.servicescommon.EventSender) ZooKeeperMasterModel(com.spotify.helios.master.ZooKeeperMasterModel) DefaultZooKeeperClient(com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient) Before(org.junit.Before)

Aggregations

DefaultZooKeeperClient (com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient)4 ZooKeeperClientProvider (com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider)4 ZooKeeperMasterModel (com.spotify.helios.master.ZooKeeperMasterModel)3 EventSender (com.spotify.helios.servicescommon.EventSender)3 Before (org.junit.Before)3 ZooKeeperClient (com.spotify.helios.servicescommon.coordination.ZooKeeperClient)2 ZooKeeperTestingServerManager (com.spotify.helios.ZooKeeperTestingServerManager)1 JobId (com.spotify.helios.common.descriptors.JobId)1 JobDeleteResponse (com.spotify.helios.common.protocol.JobDeleteResponse)1 RetryPolicy (org.apache.curator.RetryPolicy)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)1 Test (org.junit.Test)1