Search in sources :

Example 1 with EventSender

use of com.spotify.helios.servicescommon.EventSender in project helios by spotify.

the class ZooKeeperAgentModel method setTaskStatus.

/**
   * Set the {@link TaskStatus} for the job identified by {@code jobId}.
   */
@Override
public void setTaskStatus(final JobId jobId, final TaskStatus status) throws InterruptedException {
    log.debug("setting task status: {}", status);
    taskStatuses.put(jobId.toString(), status.toJsonBytes());
    if (historyWriter != null) {
        try {
            historyWriter.saveHistoryItem(status);
        } catch (Exception e) {
            // Log error here and keep going as saving task history is not critical.
            // This is to prevent bad data in the queue from screwing up the actually important Helios
            // agent operations.
            log.error("Error saving task status {} to ZooKeeper: {}", status, e);
        }
    }
    final TaskStatusEvent event = new TaskStatusEvent(status, System.currentTimeMillis(), agent);
    final byte[] message = event.toJsonBytes();
    for (final EventSender sender : eventSenders) {
        sender.send(taskStatusEventTopic, message);
    }
}
Also used : TaskStatusEvent(com.spotify.helios.common.descriptors.TaskStatusEvent) EventSender(com.spotify.helios.servicescommon.EventSender) IOException(java.io.IOException)

Example 2 with EventSender

use of com.spotify.helios.servicescommon.EventSender 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)

Example 3 with EventSender

use of com.spotify.helios.servicescommon.EventSender 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 EventSender

use of com.spotify.helios.servicescommon.EventSender 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)

Aggregations

EventSender (com.spotify.helios.servicescommon.EventSender)4 ZooKeeperMasterModel (com.spotify.helios.master.ZooKeeperMasterModel)3 DefaultZooKeeperClient (com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient)3 ZooKeeperClientProvider (com.spotify.helios.servicescommon.coordination.ZooKeeperClientProvider)3 Before (org.junit.Before)3 ZooKeeperTestingServerManager (com.spotify.helios.ZooKeeperTestingServerManager)1 TaskStatusEvent (com.spotify.helios.common.descriptors.TaskStatusEvent)1 ZooKeeperClient (com.spotify.helios.servicescommon.coordination.ZooKeeperClient)1 IOException (java.io.IOException)1 RetryPolicy (org.apache.curator.RetryPolicy)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)1