Search in sources :

Example 36 with SingularityPendingTaskId

use of com.hubspot.singularity.SingularityPendingTaskId in project Singularity by HubSpot.

the class SingularityPendingTaskIdMigration method createFrom.

public SingularityPendingTaskId createFrom(String string, long createdAt) {
    if (Character.isDigit(string.charAt(string.length() - 1))) {
        LOG.warn("Not migrating {} - it appears to be migrated already", string);
        return SingularityPendingTaskId.valueOf(string);
    }
    String[] splits = null;
    try {
        splits = JavaUtils.reverseSplit(string, 5, "-");
    } catch (IllegalStateException ise) {
        throw new InvalidSingularityTaskIdException(String.format("PendingTaskId %s was invalid (%s)", string, ise.getMessage()));
    }
    try {
        final String requestId = splits[0];
        final String deployId = splits[1];
        final long nextRunAt = Long.parseLong(splits[2]);
        final int instanceNo = Integer.parseInt(splits[3]);
        final PendingType pendingType = PendingType.valueOf(splits[4]);
        return new SingularityPendingTaskId(requestId, deployId, nextRunAt, instanceNo, pendingType, createdAt);
    } catch (IllegalArgumentException e) {
        throw new InvalidSingularityTaskIdException(String.format("PendingTaskId %s had an invalid parameter (%s)", string, e.getMessage()));
    }
}
Also used : InvalidSingularityTaskIdException(com.hubspot.singularity.InvalidSingularityTaskIdException) PendingType(com.hubspot.singularity.SingularityPendingRequest.PendingType) SingularityPendingTaskId(com.hubspot.singularity.SingularityPendingTaskId)

Aggregations

SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)36 SingularityRequest (com.hubspot.singularity.SingularityRequest)16 Test (org.junit.Test)16 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)15 SingularityRequestBuilder (com.hubspot.singularity.SingularityRequestBuilder)9 SingularityPendingTask (com.hubspot.singularity.SingularityPendingTask)8 SingularityRunNowRequest (com.hubspot.singularity.api.SingularityRunNowRequest)8 SingularityPendingRequest (com.hubspot.singularity.SingularityPendingRequest)7 SingularityPendingTaskBuilder (com.hubspot.singularity.SingularityPendingTaskBuilder)7 SingularityDeploy (com.hubspot.singularity.SingularityDeploy)6 SingularityTask (com.hubspot.singularity.SingularityTask)6 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)5 SingularityDeployKey (com.hubspot.singularity.SingularityDeployKey)4 PendingType (com.hubspot.singularity.SingularityPendingRequest.PendingType)4 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)4 Optional (com.google.common.base.Optional)3 Inject (com.google.inject.Inject)3 RequestType (com.hubspot.singularity.RequestType)3 SingularityDeployBuilder (com.hubspot.singularity.SingularityDeployBuilder)3 ArrayList (java.util.ArrayList)3