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);
}
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);
}
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);
}
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();
}
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();
}
Aggregations