Search in sources :

Example 6 with PendingType

use of com.hubspot.singularity.SingularityPendingRequest.PendingType in project Singularity by HubSpot.

the class SingularityPendingTaskId method valueOf.

public static SingularityPendingTaskId valueOf(String string) {
    String[] splits = null;
    try {
        splits = JavaUtils.reverseSplit(string, 6, "-");
    } 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]);
        final long createdAt = Long.parseLong(splits[5]);
        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 : PendingType(com.hubspot.singularity.SingularityPendingRequest.PendingType)

Example 7 with PendingType

use of com.hubspot.singularity.SingularityPendingRequest.PendingType 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

PendingType (com.hubspot.singularity.SingularityPendingRequest.PendingType)7 SingularityPendingRequest (com.hubspot.singularity.SingularityPendingRequest)3 SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)2 SingularityRequest (com.hubspot.singularity.SingularityRequest)2 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)2 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)2 SingularityRunNowRequest (com.hubspot.singularity.api.SingularityRunNowRequest)2 Timed (com.codahale.metrics.annotation.Timed)1 ImmutableList (com.google.common.collect.ImmutableList)1 InvalidSingularityTaskIdException (com.hubspot.singularity.InvalidSingularityTaskIdException)1 RequestState (com.hubspot.singularity.RequestState)1 SingularityDeployStatistics (com.hubspot.singularity.SingularityDeployStatistics)1 SingularityPendingDeploy (com.hubspot.singularity.SingularityPendingDeploy)1 SingularityPendingRequestBuilder (com.hubspot.singularity.SingularityPendingRequestBuilder)1 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)1 SingularityTaskHistoryUpdate (com.hubspot.singularity.SingularityTaskHistoryUpdate)1 SingularityExpiringBounce (com.hubspot.singularity.expiring.SingularityExpiringBounce)1 RFC5545Schedule (com.hubspot.singularity.helpers.RFC5545Schedule)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1