Search in sources :

Example 1 with OrbTrackerMember

use of org.goldenorb.jet.OrbTrackerMember in project goldenorb by jzachr.

the class TestLeaderGroupMonitor method testInitializing.

/**
   * Test initializing a monitor on a leader group that already contains members
   * 
   * @throws OrbZKFailure
   * @throws InterruptedException
   */
@Test
public void testInitializing() throws OrbZKFailure, InterruptedException {
    int num_nodes = 10;
    for (int i = 0; i < num_nodes; i++) {
        OrbTrackerMember otm = new OrbTrackerMember();
        otm.setAvailablePartitions(1);
        otm.setHostname("abc");
        otm.setInUsePartitions(1);
        otm.setLeader(false);
        otm.setPartitionCapacity(1);
        otm.setPort(1);
        otm.setReservedPartitions(1);
        ZookeeperUtils.tryToCreateNode(zk, leaderGroupPath + "/member", otm, CreateMode.EPHEMERAL_SEQUENTIAL);
    }
    CountDownLatch latch = new CountDownLatch(num_nodes);
    TServer server = new TServer(latch);
    Map<String, OrbTrackerMemberData> map = server.getMemberData();
    assertTrue(map.size() == 0);
    new LeaderGroupMonitor(leaderGroupPath, server, zk);
    latch.await();
    map = server.getMemberData();
    assertTrue(map.size() == num_nodes);
// ZookeeperUtils.recursiveDelete(zk, leaderGroupPath);
}
Also used : OrbTrackerMemberData(org.goldenorb.client.OrbTrackerMemberData) OrbTrackerMember(org.goldenorb.jet.OrbTrackerMember) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 2 with OrbTrackerMember

use of org.goldenorb.jet.OrbTrackerMember in project goldenorb by jzachr.

the class TestLeaderGroupMonitor method testAddingNodes.

/**
   * Test adding nodes to alreading initialized watcher
   * 
   * @throws OrbZKFailure
   * @throws InterruptedException
   */
@Test
public void testAddingNodes() throws OrbZKFailure, InterruptedException {
    int num_nodes = 10;
    CountDownLatch latch = new CountDownLatch(num_nodes);
    TServer server = new TServer(latch);
    Map<String, OrbTrackerMemberData> map = server.getMemberData();
    assertTrue(map.size() == 0);
    new LeaderGroupMonitor(leaderGroupPath, server, zk);
    for (int i = 0; i < num_nodes; i++) {
        OrbTrackerMember otm = new OrbTrackerMember();
        otm.setAvailablePartitions(1);
        otm.setHostname("abc");
        otm.setInUsePartitions(1);
        otm.setLeader(false);
        otm.setPartitionCapacity(1);
        otm.setPort(1);
        otm.setReservedPartitions(1);
        ZookeeperUtils.tryToCreateNode(zk, leaderGroupPath + "/member", otm, CreateMode.EPHEMERAL_SEQUENTIAL);
    }
    latch.await();
    map = server.getMemberData();
    assertEquals(num_nodes, map.size());
    // adding five new nodes
    latch = new CountDownLatch(5);
    server.setLatcher(latch);
    for (int i = 0; i < 5; i++) {
        OrbTrackerMember otm = new OrbTrackerMember();
        otm.setAvailablePartitions(1);
        otm.setHostname("abc");
        otm.setInUsePartitions(1);
        otm.setLeader(false);
        otm.setPartitionCapacity(1);
        otm.setPort(1);
        otm.setReservedPartitions(1);
        ZookeeperUtils.tryToCreateNode(zk, leaderGroupPath + "/member", otm, CreateMode.EPHEMERAL_SEQUENTIAL);
    }
    latch.await();
    map = server.getMemberData();
    assertTrue(map.size() == num_nodes + 5);
}
Also used : OrbTrackerMemberData(org.goldenorb.client.OrbTrackerMemberData) OrbTrackerMember(org.goldenorb.jet.OrbTrackerMember) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 3 with OrbTrackerMember

use of org.goldenorb.jet.OrbTrackerMember in project goldenorb by jzachr.

the class TestOrbTrackerMemberDataServiceImpl method createMember.

public void createMember(int i) throws OrbZKFailure {
    OrbTrackerMember otm = new OrbTrackerMember();
    otm.setAvailablePartitions(i);
    otm.setHostname("host");
    otm.setInUsePartitions(i);
    otm.setLeader(false);
    otm.setPartitionCapacity(i);
    otm.setPort(i);
    otm.setReservedPartitions(i);
    ZookeeperUtils.tryToCreateNode(zk, leaderGroupPath, otm, CreateMode.EPHEMERAL_SEQUENTIAL);
}
Also used : OrbTrackerMember(org.goldenorb.jet.OrbTrackerMember)

Example 4 with OrbTrackerMember

use of org.goldenorb.jet.OrbTrackerMember in project goldenorb by jzachr.

the class JobManager method jobDeath.

/**
 * 
 * @param  OrbJob job
 */
private void jobDeath(OrbJob job) throws OrbZKFailure {
    logger.info("jobDeath " + job.getJobNumber());
    synchronized (job) {
        fireEvent(new JobDeathEvent(job.getJobNumber()));
        job.getJobStillActiveInterface().kill();
        job.getDeathAndCompleteWatcher().kill();
        job.getHeartbeatWatcher().kill();
    }
    for (OrbTrackerMember orbTrackerMember : orbTrackerMembers) {
        orbTrackerMember.killJob(job.getJobNumber());
    }
    logger.info("Shutting down partition instances");
    logger.info("Number of tries: " + job.getTries());
    if (job.getTries() > orbConf.getMaximumJobTries()) {
        ZookeeperUtils.recursiveDelete(zk, jobsInProgressPath + "/" + job.getJobNumber());
        ZookeeperUtils.deleteNodeIfEmpty(zk, jobsInProgressPath + "/" + job.getJobNumber());
        removeJobFromQueue(job);
    } else {
        ZookeeperUtils.recursiveDelete(zk, jobsInProgressPath + "/" + job.getJobNumber());
        ZookeeperUtils.deleteNodeIfEmpty(zk, jobsInProgressPath + "/" + job.getJobNumber());
        job.incrementTries();
        logger.info("Incrementing tries for: " + job.getJobNumber());
    }
    synchronized (activeJobs) {
        activeJobs.remove(job.getJobNumber());
        logger.info("Removing job: " + job.getJobNumber() + " from activeJobs.");
    // TODO tell the other OrbTrackers to kill the partitions associated with the job.
    }
    tryToLaunchJob();
}
Also used : OrbTrackerMember(org.goldenorb.jet.OrbTrackerMember) JobDeathEvent(org.goldenorb.event.job.JobDeathEvent)

Example 5 with OrbTrackerMember

use of org.goldenorb.jet.OrbTrackerMember in project goldenorb by jzachr.

the class JobManager method jobComplete.

/**
 * 
 * @param  OrbJob job
 */
private void jobComplete(OrbJob job) throws OrbZKFailure {
    synchronized (job) {
        job.getJobStillActiveInterface().kill();
        job.getDeathAndCompleteWatcher().kill();
        job.getHeartbeatWatcher().kill();
    }
    for (OrbTrackerMember orbTrackerMember : orbTrackerMembers) {
        orbTrackerMember.killJob(job.getJobNumber());
    }
    ZookeeperUtils.recursiveDelete(zk, jobsInProgressPath + "/" + job.getJobNumber());
    ZookeeperUtils.deleteNodeIfEmpty(zk, jobsInProgressPath + "/" + job.getJobNumber());
    removeJobFromQueue(job);
    logger.info("********** Job {} removed: {}", job.getJobNumber(), new Date().getTime());
    removeJobsHDFSfiles(job);
    tryToLaunchJob();
}
Also used : OrbTrackerMember(org.goldenorb.jet.OrbTrackerMember) Date(java.util.Date)

Aggregations

OrbTrackerMember (org.goldenorb.jet.OrbTrackerMember)10 CountDownLatch (java.util.concurrent.CountDownLatch)6 OrbTrackerMemberData (org.goldenorb.client.OrbTrackerMemberData)6 Test (org.junit.Test)5 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInput (java.io.DataInput)1 DataInputStream (java.io.DataInputStream)1 DataOutput (java.io.DataOutput)1 DataOutputStream (java.io.DataOutputStream)1 Date (java.util.Date)1 JobDeathEvent (org.goldenorb.event.job.JobDeathEvent)1 Before (org.junit.Before)1