use of org.platformlayer.jobs.model.JobData in project platformlayer by platformlayer.
the class FederatedPlatformLayerClient method deleteItem.
@Override
public JobData deleteItem(PlatformLayerKey key) throws PlatformLayerClientException {
MappedPlatformLayerKey mapped = mapToChild(key);
JobData jobData = mapped.child.client.deleteItem(key);
return mapped.child.setHost(jobData);
}
use of org.platformlayer.jobs.model.JobData in project platformlayer by platformlayer.
the class JdbcJobRepository method mapFromEntity.
private JobData mapFromEntity(JobEntity entity, PlatformLayerKey jobKey) throws RepositoryException {
JobData data = new JobData();
data.action = actionFromXml(entity.actionXml);
data.key = jobKey;
data.targetId = PlatformLayerKey.parse(entity.target);
if (entity.lastrunId != null) {
JobExecutionData execution = new JobExecutionData();
execution.endedAt = entity.lastrunEndedAt;
execution.executionId = entity.lastrunId;
execution.state = entity.lastrunState;
data.lastRun = execution;
}
return data;
}
use of org.platformlayer.jobs.model.JobData in project platformlayer by platformlayer.
the class ITSolrService method testCreateAndDeleteItem.
@Test
public void testCreateAndDeleteItem() throws Exception {
String id = random.randomAlphanumericString(8);
SolrCluster solr = new SolrCluster();
solr.dnsName = id + ".test.platformlayer.org";
solr = putItem(id, solr);
solr = waitForHealthy(solr);
InetSocketAddress socketAddress = getUniqueEndpoint(solr);
Assert.assertFalse(isPortOpen(socketAddress));
openFirewall(solr, SolrConstants.API_PORT);
Assert.assertTrue(isPortOpen(socketAddress));
// TODO: Make endpoint http://<ip>:<port>/<path>...
String url = "http://" + socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort() + "/solr";
testSolr(url);
String customFieldKey = "customfield1";
SolrSchemaField field = new SolrSchemaField();
field.name = customFieldKey;
field.type = "text_general";
field.getTags().add(Tag.buildParentTag(solr.getKey()));
// TODO: Our scoping of keys is problematic now...
// If two clusters both have the same key "customfield1", they can't have the same ID
field = putItem(id + "-" + customFieldKey, field);
waitForHealthy(field);
// Currently, we need to do a manual configure operation...
// TODO: trigger this automatically
SolrServer server = getItem(id + "-0", SolrServer.class);
JobData configureJob = getContext().doConfigure(server);
waitForJobComplete(configureJob, TimeSpan.FIVE_MINUTES);
testSolrCustomField(url, customFieldKey);
}
use of org.platformlayer.jobs.model.JobData in project platformlayer by platformlayer.
the class PlatformLayerTestContext method waitForJobComplete.
public JobData waitForJobComplete(JobData job, TimeSpan timeout) throws OpsException, IOException {
TypedPlatformLayerClient client = getTypedClient();
PlatformLayerKey jobKey = job.key;
long startedAt = System.currentTimeMillis();
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new IllegalStateException("Interrupted", e);
}
if (timeout != null && timeout.hasTimedOut(startedAt)) {
throw new OpsException("Timeout waiting for job completion");
}
// TODO: We really need a "get job status" function
JobData found = null;
for (JobData candidate : client.listJobs().getJobs()) {
if (jobKey.equals(candidate.getJobKey())) {
found = candidate;
}
}
if (found == null) {
// Assume completed?
throw new IllegalStateException("Job not found in job list");
}
JobExecutionList executions = client.listJobExecutions(job.getJobKey().getItemIdString());
JobExecutionData foundExecution = null;
for (JobExecutionData candidate : executions) {
if (jobKey.equals(candidate.getJobKey())) {
foundExecution = candidate;
}
}
if (foundExecution == null) {
throw new IllegalStateException("Execution not found in execution list");
}
JobState state = foundExecution.getState();
switch(state) {
case FAILED:
case SUCCESS:
System.out.println("Job completed; state=" + state);
return found;
case RUNNING:
System.out.println("Continuing to wait for " + job.key + "; state=" + state);
break;
default:
throw new IllegalStateException("Unexpected state: " + state + " for " + job.key);
}
}
}
use of org.platformlayer.jobs.model.JobData in project platformlayer by platformlayer.
the class JobsCollectionResource method getJob.
@Path("{jobId}")
public JobResource getJob(@PathParam("jobId") String jobId) throws OpsException {
PlatformLayerKey jobKey = JobData.buildKey(getProject(), new ManagedItemId(jobId));
JobData record = jobRegistry.getJob(jobKey);
if (record == null) {
raiseNotFound();
}
JobResource jobResource = jobResourceProvider.get();
jobResource.init(record);
return jobResource;
}
Aggregations