All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.mantisrx.master.jobcluster.LabelManager Maven / Gradle / Ivy

There is a newer version: 3.1.4
Show newest version
/*
 * Copyright 2019 Netflix, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.mantisrx.master.jobcluster;

import io.mantisrx.common.Label;
import io.mantisrx.runtime.command.InvalidJobException;
import io.mantisrx.server.master.domain.JobDefinition;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class LabelManager {

    public enum SystemLabels {
        MANTIS_IS_RESUBMIT_LABEL("_mantis.isResubmit"),
        MANTIS_ARTIFACT_LABEL("_mantis.artifact"),
        MANTIS_VERSION_LABEL("_mantis.version"),
        MANTIS_SUBMITTER_LABEL("_mantis.submitter"),
        MANTIS_OWNER_EMAIL_LABEL("_mantis.ownerEmail"),
        MANTIS_CRITIALITY_LABEL("_mantis.criticality"),
        MANTIS_DATA_ORIGIN_LABEL("_mantis.dataOrigin"),
        MANTIS_JOB_TYPE_LABEL("_mantis.jobType"),
        MANTIS_RESOURCE_CLUSTER_NAME_LABEL("_mantis.resourceCluster");
        public final String label;
        SystemLabels(String s) {
            this.label = s;
        }
    };


    private static final Logger logger = LoggerFactory.getLogger(LabelManager.class);


    static int numberOfMandatoryLabels() {
        return 2;
    }
    static JobDefinition insertSystemLabels(JobDefinition resolvedJobDefn, boolean autoResubmit) {
        JobDefinition updatedJobDefn = resolvedJobDefn;
        if(autoResubmit) {
            updatedJobDefn = insertAutoResubmitLabel(resolvedJobDefn);
        }
        String artifactName = updatedJobDefn.getArtifactName();
        String version = updatedJobDefn.getVersion();

        List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy