use of org.platformlayer.PlatformLayerEndpointInfo in project platformlayer by platformlayer.
the class SchedulerImpl method toRunnable.
private Runnable toRunnable(final ActionTask task) {
final PlatformLayerKey target = task.target;
final PlatformLayerEndpointInfo endpoint = rehydrateEndpoint(task.endpoint);
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
PlatformLayerClient platformLayer = HttpPlatformLayerClient.build(httpStrategy, endpoint.getPlatformlayerBaseUrl(), endpoint.getAuthenticator(), endpoint.getProjectId(), endpoint.getTrustKeys());
platformLayer.doAction(target, task.action);
// TODO: Wait for task completion??
// TODO: Link job id??
} catch (PlatformLayerClientException e) {
log.warn("Error running action", e);
}
}
@Override
public String toString() {
return task.action + " on " + task.target;
}
};
return runnable;
}
use of org.platformlayer.PlatformLayerEndpointInfo in project platformlayer by platformlayer.
the class ScheduleController method handler.
@Handler
public void handler() throws OpsException {
if (OpsContext.isConfigure()) {
String key = model.getKey().getUrl();
PlatformLayerKey target = model.targetItem;
PlatformLayerEndpointInfo endpoint = platformLayer.getEndpointInfo(target);
JobSchedule schedule = model.schedule;
Action action = model.action;
actionScheduler.putJob(key, endpoint, schedule, target, action);
}
}
use of org.platformlayer.PlatformLayerEndpointInfo in project platformlayer by platformlayer.
the class SchedulerImpl method rehydrateEndpoint.
private static PlatformLayerEndpointInfo rehydrateEndpoint(final EndpointRecord in) {
final Authenticator authenticator;
final String platformlayerBaseUrl = in.url;
final ProjectId projectId = new ProjectId(in.project);
final List<String> trustKeys;
if (Strings.isNullOrEmpty(in.trustKeys)) {
trustKeys = Collections.emptyList();
} else {
trustKeys = Lists.newArrayList(Splitter.on(",").split(in.trustKeys));
}
{
String token = in.token;
CryptoKey secret = FathomdbCrypto.deserializeKey(Hex.fromHex(in.secret.plaintext()));
DirectAuthenticationToken authenticationToken = new DirectAuthenticationToken(token, secret);
authenticator = new DirectAuthenticator(authenticationToken);
}
PlatformLayerEndpointInfo out = new PlatformLayerEndpointInfo(authenticator, platformlayerBaseUrl, projectId, trustKeys);
return out;
}
Aggregations