http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.java deleted file mode 100644 index cda55c5..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskConfigMapper.java +++ /dev/null @@ -1,210 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.aurora.common.collections.Pair; -import org.apache.aurora.scheduler.storage.db.views.DbTaskConfig; -import org.apache.aurora.scheduler.storage.entities.IConstraint; -import org.apache.aurora.scheduler.storage.entities.IDockerContainer; -import org.apache.aurora.scheduler.storage.entities.IDockerParameter; -import org.apache.aurora.scheduler.storage.entities.IJobKey; -import org.apache.aurora.scheduler.storage.entities.ILimitConstraint; -import org.apache.aurora.scheduler.storage.entities.IMesosFetcherURI; -import org.apache.aurora.scheduler.storage.entities.IMetadata; -import org.apache.aurora.scheduler.storage.entities.ITaskConfig; -import org.apache.aurora.scheduler.storage.entities.IValueConstraint; -import org.apache.aurora.scheduler.storage.entities.IVolume; -import org.apache.ibatis.annotations.Param; - -/** - * MyBatis mapper for task config objects. - */ -interface TaskConfigMapper extends GarbageCollectedTableMapper { - - /** - * Inserts fields from a task config into the {@code task_configs} table. - * - * @param config Configuration to insert. - * @param result Container for auto-generated ID of the inserted row. - */ - void insert( - @Param("config") ITaskConfig config, - @Param("result") InsertResult result); - - /** - * Gets all task config rows referenced by a job. - * - * @param job Job to look up. - * @return Task config row container. - */ - List<DbTaskConfig> selectConfigsByJob(IJobKey job); - - /** - * Inserts the constraint association within an {@link ITaskConfig}. - * - * @param configId Task config ID. - * @param constraint Constraint to insert. - * @param result Container for auto-generated ID of the inserted row. - */ - void insertConstraint( - @Param("configId") long configId, - @Param("constraint") IConstraint constraint, - @Param("result") InsertResult result); - - /** - * Inserts the limit constraint association within an {@link IConstraint}. - * - * @param constraintId Constraint ID. - * @param constraint Constraint to insert. - */ - void insertLimitConstraint( - @Param("constraintId") long constraintId, - @Param("constraint") ILimitConstraint constraint); - - /** - * Inserts the value constraint association within an {@link IConstraint}. - * - * @param constraintId Constraint ID. - * @param constraint Constraint to insert. - * @param result Container for auto-generated ID of the inserted row. - */ - void insertValueConstraint( - @Param("constraintId") long constraintId, - @Param("constraint") IValueConstraint constraint, - @Param("result") InsertResult result); - - /** - * Inserts the values association within an {@link IValueConstraint}. - * - * @param valueConstraintId Value constraint ID. - * @param values Values to insert. - */ - void insertValueConstraintValues( - @Param("valueConstraintId") long valueConstraintId, - @Param("values") Set<String> values); - - /** - * Inserts the requested ports association within an {@link ITaskConfig}. - * - * @param configId Task config ID. - * @param ports Port names to insert. - */ - void insertRequestedPorts( - @Param("configId") long configId, - @Param("ports") Set<String> ports); - - /** - * Inserts the task links association within an {@link ITaskConfig}. - * - * @param configId Task config ID. - * @param links Task links to insert. - */ - void insertTaskLinks(@Param("configId") long configId, @Param("links") Map<String, String> links); - - /** - * Inserts the container association within an {@link ITaskConfig}. - * - * @param configId Task config ID. - * @param container Container to insert. - */ - void insertContainer( - @Param("configId") long configId, - @Param("container") IDockerContainer container, - @Param("result") InsertResult result); - - /** - * Inserts docker parameters in association with an {@link IDockerContainer}. - * - * @param containerId Docker container row ID. - * @param parameters Parameters to insert. - */ - void insertDockerParameters( - @Param("containerId") long containerId, - @Param("parameters") List<IDockerParameter> parameters); - - /** - * Inserts the metadata association within an {@link ITaskConfig}. - * - * @param configId Task config ID. - * @param metadata Metadata associated with the task config. - */ - void insertMetadata( - @Param("configId") long configId, - @Param("metadata") Set<IMetadata> metadata); - - /** - * Inserts the Mesos Fetcher URIs in association with an {@link ITaskConfig}. - * - * @param configId Task config ID. - * @param uris Resources Mesos Fetcher should place in sandbox. - */ - void insertMesosFetcherUris( - @Param("configId") long configId, - @Param("uris") Set<IMesosFetcherURI> uris); - - /** - * Deletes task configs. - * - * @param configIds Configs to delete. - */ - void delete(@Param("configIds") Set<Long> configIds); - - /** - * Inserts an AppC image association with an {@link ITaskConfig}. - * - * @param configId Task config ID. - * @param name The name of the image. - * @param imageId The image's identifier. - */ - void insertAppcImage( - @Param("configId") long configId, - @Param("name") String name, - @Param("imageId") String imageId); - - /** - * Inserts a Docker image association with an {@link ITaskConfig}. - * - * @param configId Task config ID. - * @param name The name of the image. - * @param tag The image's tag. - */ - void insertDockerImage( - @Param("configId") long configId, - @Param("name") String name, - @Param("tag") String tag); - - /** - * Inserts task resources. - * - * @param configId Task config ID. - * @param values Resources to insert. - */ - void insertResources( - @Param("configId") long configId, - @Param("values") List<Pair<Integer, String>> values); - - /** - * Inserts a task's volume mounts. - * - * @param configId Task config ID. - * @param volumes Volumes to insert. - */ - void insertVolumes( - @Param("configId") long configId, - @Param("volumes") List<IVolume> volumes); -}
http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/TaskMapper.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskMapper.java b/src/main/java/org/apache/aurora/scheduler/storage/db/TaskMapper.java deleted file mode 100644 index cbcef84..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/TaskMapper.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Nullable; - -import org.apache.aurora.gen.JobKey; -import org.apache.aurora.scheduler.storage.db.views.DbScheduledTask; -import org.apache.aurora.scheduler.storage.entities.IScheduledTask; -import org.apache.aurora.scheduler.storage.entities.ITaskEvent; -import org.apache.aurora.scheduler.storage.entities.ITaskQuery; -import org.apache.ibatis.annotations.Param; - -/** - * MyBatis mapper for scheduled tasks. - */ -interface TaskMapper { - - /** - * Inserts a scheduled task. - * - * @param task Task to insert. - */ - void insertScheduledTask( - @Param("task") IScheduledTask task, - @Param("configId") long configId, - @Param("result") InsertResult result); - - /** - * Gets tasks based on a query. - * - * @param query Query to use as a filter for tasks. - * @return Tasks matching the query. - */ - List<DbScheduledTask> select(ITaskQuery query); - - /** - * Gets a task by ID. - * - * @param taskId ID of the task to fetch. - * @return Task with the specified ID. - */ - @Nullable - DbScheduledTask selectById(@Param("taskId") String taskId); - - /** - * Gets job keys of all stored tasks. - * - * @return Job keys. - */ - Set<JobKey> selectJobKeys(); - - /** - * Inserts the task events association within an - * {@link org.apache.aurora.scheduler.storage.entities.IScheduledTask}. - * - * @param taskRowId Task row ID. - * @param events Events to insert. - */ - void insertTaskEvents( - @Param("taskRowId") long taskRowId, - @Param("events") List<ITaskEvent> events); - - /** - * Inserts the assigned ports association within an - * {@link org.apache.aurora.scheduler.storage.entities.IScheduledTask}. - * - * @param taskRowId Task row ID. - * @param ports Assigned ports to insert. - */ - void insertPorts(@Param("taskRowId") long taskRowId, @Param("ports") Map<String, Integer> ports); - - /** - * Deletes all task rows. - */ - void truncate(); - - /** - * Deletes task rows by ID. - * - * @param taskIds IDs of tasks to delete. - */ - void deleteTasks(@Param("taskIds") Set<String> taskIds); -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V001_CreateAppcImagesTable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V001_CreateAppcImagesTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V001_CreateAppcImagesTable.java deleted file mode 100644 index 0735772..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V001_CreateAppcImagesTable.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; - -import org.apache.ibatis.migration.MigrationScript; - -public class V001_CreateAppcImagesTable implements MigrationScript { - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(1L); - } - - @Override - public String getDescription() { - return "Create the task_config_appc_images table."; - } - - @Override - public String getUpScript() { - return "CREATE TABLE IF NOT EXISTS task_config_appc_images(" - + "id IDENTITY," - + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE," - + "name VARCHAR NOT NULL," - + "image_id VARCHAR NOT NULL," - + "UNIQUE(task_config_id)" - + ");"; - } - - @Override - public String getDownScript() { - return "DROP TABLE IF EXISTS task_config_appc_images;"; - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V002_CreateDockerImagesTable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V002_CreateDockerImagesTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V002_CreateDockerImagesTable.java deleted file mode 100644 index 9a1ef28..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V002_CreateDockerImagesTable.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; - -import org.apache.ibatis.migration.MigrationScript; - -public class V002_CreateDockerImagesTable implements MigrationScript { - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(2L); - } - - @Override - public String getDescription() { - return "Create the task_config_docker_images table."; - } - - @Override - public String getUpScript() { - return "CREATE TABLE IF NOT EXISTS task_config_docker_images(" - + "id IDENTITY," - + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE," - + "name VARCHAR NOT NULL," - + "tag VARCHAR NOT NULL," - + "UNIQUE(task_config_id)" - + ");"; - } - - @Override - public String getDownScript() { - return "DROP TABLE IF EXISTS task_config_docker_images;"; - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V003_CreateResourceTypesTable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V003_CreateResourceTypesTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V003_CreateResourceTypesTable.java deleted file mode 100644 index 76c6916..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V003_CreateResourceTypesTable.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; -import java.util.Arrays; -import java.util.stream.Collectors; - -import org.apache.aurora.scheduler.resources.ResourceType; -import org.apache.ibatis.migration.MigrationScript; - -public class V003_CreateResourceTypesTable implements MigrationScript { - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(3L); - } - - @Override - public String getDescription() { - return "Create the resource_types table."; - } - @Override - public String getUpScript() { - return "CREATE TABLE IF NOT EXISTS resource_types(" - + "id INT PRIMARY KEY," - + "name VARCHAR NOT NULL," - + "UNIQUE(name)" - + ");\n" - + populateScript(); - } - - @Override - public String getDownScript() { - return "DROP TABLE IF EXISTS resource_types;"; - } - - private static String populateScript() { - return Arrays.stream(ResourceType.values()) - .map(e -> String.format( - "MERGE INTO resource_types(id, name) KEY(name) VALUES (%d, '%s');", - e.getValue(), - e.name())) - .collect(Collectors.joining("\n")); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V004_CreateTaskResourceTable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V004_CreateTaskResourceTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V004_CreateTaskResourceTable.java deleted file mode 100644 index af106a8..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V004_CreateTaskResourceTable.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; - -import org.apache.aurora.scheduler.resources.ResourceType; -import org.apache.ibatis.migration.MigrationScript; - -public class V004_CreateTaskResourceTable implements MigrationScript { - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(4L); - } - - @Override - public String getDescription() { - return "Create the task_resource table."; - } - - @Override - public String getUpScript() { - return "CREATE TABLE IF NOT EXISTS task_resource(" - + "id IDENTITY," - + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE," - + "type_id INT NOT NULL REFERENCES resource_types(id)," - + "value VARCHAR NOT NULL," - + "UNIQUE(task_config_id, type_id, value)" - + ");\n" - + migrateScript(); - } - - @Override - public String getDownScript() { - return "DROP TABLE IF EXISTS task_resource;"; - } - - private static String migrateScript() { - return "MERGE INTO task_resource(task_config_id, type_id, value) " - + "KEY(task_config_id, type_id, value) " - + "SELECT t.id, rt.id, t.num_cpus FROM task_configs t " - + "JOIN resource_types rt ON rt.name = " - + String.format("'%s';%n", ResourceType.CPUS.name()) - - + "MERGE INTO task_resource(task_config_id, type_id, value) " - + "KEY(task_config_id, type_id, value) " - + "SELECT t.id, rt.id, t.ram_mb FROM task_configs t " - + "JOIN resource_types rt ON rt.NAME = " - + String.format("'%s';%n", ResourceType.RAM_MB.name()) - - + "MERGE INTO task_resource(task_config_id, type_id, value) " - + "KEY(task_config_id, type_id, value) " - + "SELECT t.id, rt.id, t.disk_mb FROM task_configs t " - + "JOIN resource_types rt ON rt.NAME = " - + String.format("'%s';%n", ResourceType.DISK_MB.name()) - - + "MERGE INTO task_resource(task_config_id, type_id, value) " - + "KEY(task_config_id, type_id, value) " - + "SELECT tcrp.task_config_id, rt.id, tcrp.port_name FROM task_config_requested_ports tcrp " - + "JOIN resource_types rt ON rt.NAME = " - + String.format("'%s';%n", ResourceType.PORTS.name()); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V005_CreateQuotaResourceTable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V005_CreateQuotaResourceTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V005_CreateQuotaResourceTable.java deleted file mode 100644 index cd06346..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V005_CreateQuotaResourceTable.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; - -import org.apache.aurora.scheduler.resources.ResourceType; -import org.apache.ibatis.migration.MigrationScript; - -public class V005_CreateQuotaResourceTable implements MigrationScript { - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(5L); - } - - @Override - public String getDescription() { - return "Create the quota_resource table."; - } - - @Override - public String getUpScript() { - return "CREATE TABLE IF NOT EXISTS quota_resource(" - + "id IDENTITY," - + "quota_id BIGINT NOT NULL REFERENCES quotas(id) ON DELETE CASCADE," - + "type_id INT NOT NULL REFERENCES resource_types(id)," - + "value VARCHAR NOT NULL," - + "UNIQUE(quota_id, type_id)" - + ");\n" - + migrateScript(); - } - - @Override - public String getDownScript() { - return "DROP TABLE IF EXISTS quota_resource;"; - } - - private static String migrateScript() { - return "MERGE INTO quota_resource(quota_id, type_id, value) " - + "KEY(quota_id, type_id, value) " - + "SELECT q.id, rt.id, q.num_cpus FROM quotas q " - + "JOIN resource_types rt ON rt.name = " - + String.format("'%s';%n", ResourceType.CPUS.name()) - - + "MERGE INTO quota_resource(quota_id, type_id, value) " - + "KEY(quota_id, type_id, value) " - + "SELECT q.id, rt.id, q.ram_mb FROM quotas q " - + "JOIN resource_types rt ON rt.name = " - + String.format("'%s';%n", ResourceType.RAM_MB.name()) - - + "MERGE INTO quota_resource(quota_id, type_id, value) " - + "KEY(quota_id, type_id, value) " - + "SELECT q.id, rt.id, q.disk_mb FROM quotas q " - + "JOIN resource_types rt ON rt.name = " - + String.format("'%s';%n", ResourceType.DISK_MB.name()); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V006_PopulateTierField.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V006_PopulateTierField.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V006_PopulateTierField.java deleted file mode 100644 index ac85b54..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V006_PopulateTierField.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; - -import org.apache.ibatis.migration.MigrationScript; - -public class V006_PopulateTierField implements MigrationScript { - - private static final String PREFERRED_TIER_NAME = "preferred"; - private static final String PREEMPTIBLE_TIER_NAME = "preemptible"; - - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(6L); - } - - @Override - public String getDescription() { - return "Populate task_configs.tier field."; - } - - @Override - public String getUpScript() { - return "UPDATE task_configs " - + String.format( - "SET tier = CASEWHEN(production = 1, '%s', '%s') ", - PREFERRED_TIER_NAME, - PREEMPTIBLE_TIER_NAME) - + "WHERE tier IS NULL;"; - } - - @Override - public String getDownScript() { - return "UPDATE task_configs " - + "SET production = 1 " - + String.format("WHERE tier = '%s';", PREFERRED_TIER_NAME); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V007_CreateMesosFetcherURIsTable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V007_CreateMesosFetcherURIsTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V007_CreateMesosFetcherURIsTable.java deleted file mode 100644 index d474e17..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V007_CreateMesosFetcherURIsTable.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; - -import org.apache.ibatis.migration.MigrationScript; - -public class V007_CreateMesosFetcherURIsTable implements MigrationScript { - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(7L); - } - - @Override - public String getDescription() { - return "Create the task_config_mesos_fetcher_uris table."; - } - - @Override - public String getUpScript() { - return "CREATE TABLE IF NOT EXISTS task_config_mesos_fetcher_uris(" - + "id IDENTITY," - + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE," - + "value VARCHAR NOT NULL," - + "extract BOOLEAN NOT NULL," - + "cache BOOLEAN NOT NULL" - + ");"; - } - - @Override - public String getDownScript() { - return "DROP TABLE IF EXISTS task_config_mesos_fetcher_uris;"; - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V008_CreateUpdateMetadataTable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V008_CreateUpdateMetadataTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V008_CreateUpdateMetadataTable.java deleted file mode 100644 index bc86271..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V008_CreateUpdateMetadataTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; - -import org.apache.ibatis.migration.MigrationScript; - -public class V008_CreateUpdateMetadataTable implements MigrationScript { - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(8L); - } - - @Override - public String getDescription() { - return "Create the job_update_metadata table."; - } - - @Override - public String getUpScript() { - return "CREATE TABLE IF NOT EXISTS job_update_metadata(" - + "id IDENTITY," - + "update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE," - + "key VARCHAR NOT NULL," - + "value VARCHAR NOT NULL" - + ");"; - } - - @Override - public String getDownScript() { - return "DROP TABLE IF EXISTS job_update_metadata;"; - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V009_CreateContainerVolumesTable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V009_CreateContainerVolumesTable.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V009_CreateContainerVolumesTable.java deleted file mode 100644 index f6cd06a..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V009_CreateContainerVolumesTable.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; - -import org.apache.ibatis.migration.MigrationScript; - -public class V009_CreateContainerVolumesTable implements MigrationScript { - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(9L); - } - - @Override - public String getDescription() { - return "Create the task_config_volumes and volume_modes tables"; - } - - @Override - public String getUpScript() { - return "CREATE TABLE IF NOT EXISTS volume_modes(" - + "id INT PRIMARY KEY," - + "name VARCHAR NOT NULL," - + "UNIQUE(name)" - + ");" - + "CREATE TABLE IF NOT EXISTS task_config_volumes(" - + "id IDENTITY," - + "task_config_id BIGINT NOT NULL REFERENCES task_configs(id) ON DELETE CASCADE," - + "host_path VARCHAR NOT NULL," - + "container_path VARCHAR NOT NULL," - + "mode INT NOT NULL REFERENCES volume_modes(id)," - + "UNIQUE(task_config_id)" - + ");"; - } - - @Override - public String getDownScript() { - return "DROP TABLE IF EXISTS volume_modes;" - + "DROP TABLE IF EXISTS task_config_volumes;"; - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V010_RemoveUniqueConstraint.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V010_RemoveUniqueConstraint.java b/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V010_RemoveUniqueConstraint.java deleted file mode 100644 index 08c38f3..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/migration/V010_RemoveUniqueConstraint.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.migration; - -import java.math.BigDecimal; - -import org.apache.ibatis.migration.MigrationScript; - -public class V010_RemoveUniqueConstraint implements MigrationScript { - @Override - public BigDecimal getId() { - return BigDecimal.valueOf(10L); - } - - @Override - public String getDescription() { - return "Remove unique constraint in task_config_volumes"; - } - - @Override - public String getUpScript() { - // The constraint name is taken from the schema so it is always constant. - return "ALTER TABLE IF EXISTS task_config_volumes DROP CONSTRAINT IF EXISTS CONSTRAINT_654B;"; - } - - @Override - public String getDownScript() { - return "ALTER TABLE IF EXISTS task_config_volumes ADD UNIQUE(task_config_id);"; - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java deleted file mode 100644 index 69f125b..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.typehandlers; - -import java.sql.CallableStatement; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import org.apache.ibatis.type.JdbcType; -import org.apache.ibatis.type.TypeHandler; -import org.apache.thrift.TEnum; - -import static com.google.common.base.Preconditions.checkState; - -/** - * Type handler for fields of type {@link TEnum}. Implementers need only override - * {@link #fromValue(int)}. - * - * @param <T> Enum type. - */ -abstract class AbstractTEnumTypeHandler<T extends TEnum> implements TypeHandler<T> { - - /** - * Finds the enum value associated with the provided integer identity. - * - * @param value Value to find in the enum values. - * @return Enum value associated with {@code value}. - */ - protected abstract T fromValue(int value); - - @Override - public final void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) - throws SQLException { - - ps.setInt(i, parameter.getValue()); - } - - @Override - public final T getResult(ResultSet rs, String columnName) throws SQLException { - int i = rs.getInt(columnName); - checkState(!rs.wasNull()); - return fromValue(i); - } - - @Override - public final T getResult(ResultSet rs, int columnIndex) throws SQLException { - int i = rs.getInt(columnIndex); - checkState(!rs.wasNull()); - return fromValue(i); - } - - @Override - public final T getResult(CallableStatement cs, int columnIndex) throws SQLException { - int i = cs.getInt(columnIndex); - checkState(!cs.wasNull()); - return fromValue(i); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/CronCollisionPolicyTypeHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/CronCollisionPolicyTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/CronCollisionPolicyTypeHandler.java deleted file mode 100644 index b87a29f..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/CronCollisionPolicyTypeHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.typehandlers; - -import org.apache.aurora.gen.CronCollisionPolicy; - -/** - * Type handler for {@link CronCollisionPolicy}. - */ -public class CronCollisionPolicyTypeHandler extends AbstractTEnumTypeHandler<CronCollisionPolicy> { - @Override - protected CronCollisionPolicy fromValue(int value) { - return CronCollisionPolicy.findByValue(value); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateActionTypeHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateActionTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateActionTypeHandler.java deleted file mode 100644 index 85ead70..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateActionTypeHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.typehandlers; - -import org.apache.aurora.gen.JobUpdateAction; - -/** - * Type handler for {@link JobUpdateAction}. - */ -public class JobUpdateActionTypeHandler extends AbstractTEnumTypeHandler<JobUpdateAction> { - @Override - protected JobUpdateAction fromValue(int value) { - return JobUpdateAction.findByValue(value); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateStatusTypeHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateStatusTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateStatusTypeHandler.java deleted file mode 100644 index 2848bf8..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/JobUpdateStatusTypeHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.typehandlers; - -import org.apache.aurora.gen.JobUpdateStatus; - -/** - * Type handler for {@link JobUpdateStatus}. - */ -public class JobUpdateStatusTypeHandler extends AbstractTEnumTypeHandler<JobUpdateStatus> { - @Override - protected JobUpdateStatus fromValue(int value) { - return JobUpdateStatus.findByValue(value); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/MaintenanceModeTypeHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/MaintenanceModeTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/MaintenanceModeTypeHandler.java deleted file mode 100644 index 8373ec7..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/MaintenanceModeTypeHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.typehandlers; - -import org.apache.aurora.gen.MaintenanceMode; - -/** - * Type handler for {@link MaintenanceMode}. - */ -public class MaintenanceModeTypeHandler extends AbstractTEnumTypeHandler<MaintenanceMode> { - @Override - protected MaintenanceMode fromValue(int value) { - return MaintenanceMode.findByValue(value); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ResourceTypeHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ResourceTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ResourceTypeHandler.java deleted file mode 100644 index e1bb7fd..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ResourceTypeHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.typehandlers; - -import org.apache.aurora.scheduler.resources.ResourceType; - -/** - * Type handler for {@link ResourceType} enum. - */ -public class ResourceTypeHandler extends AbstractTEnumTypeHandler<ResourceType> { - @Override - protected ResourceType fromValue(int value) { - return ResourceType.fromIdValue(value); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ScheduleStatusTypeHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ScheduleStatusTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ScheduleStatusTypeHandler.java deleted file mode 100644 index b6b4f25..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/ScheduleStatusTypeHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.typehandlers; - -import org.apache.aurora.gen.ScheduleStatus; - -/** - * Type handler for {@link ScheduleStatus}. - */ -public class ScheduleStatusTypeHandler extends AbstractTEnumTypeHandler<ScheduleStatus> { - @Override - protected ScheduleStatus fromValue(int value) { - return ScheduleStatus.findByValue(value); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/TypeHandlers.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/TypeHandlers.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/TypeHandlers.java deleted file mode 100644 index 07e8c0b..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/TypeHandlers.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.typehandlers; - -import java.util.List; - -import com.google.common.collect.ImmutableList; - -import org.apache.ibatis.type.TypeHandler; - -/** - * Utility class to access the available type handler classes. - */ -public final class TypeHandlers { - private TypeHandlers() { - // Utility class. - } - - public static List<Class<? extends TypeHandler<?>>> getAll() { - return ImmutableList.<Class<? extends TypeHandler<?>>>builder() - .add(CronCollisionPolicyTypeHandler.class) - .add(JobUpdateActionTypeHandler.class) - .add(JobUpdateStatusTypeHandler.class) - .add(MaintenanceModeTypeHandler.class) - .add(ScheduleStatusTypeHandler.class) - .add(ResourceTypeHandler.class) - .add(VolumeModeTypeHandler.class) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/VolumeModeTypeHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/VolumeModeTypeHandler.java b/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/VolumeModeTypeHandler.java deleted file mode 100644 index 97f65e4..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/VolumeModeTypeHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.typehandlers; - -import org.apache.aurora.gen.Mode; - -public class VolumeModeTypeHandler extends AbstractTEnumTypeHandler<Mode> { - @Override - protected Mode fromValue(int value) { - return Mode.findByValue(value); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResource.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResource.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResource.java deleted file mode 100644 index 95a6de3..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResource.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import org.apache.aurora.gen.Resource; -import org.apache.aurora.scheduler.resources.ResourceType; -import org.apache.aurora.scheduler.storage.entities.IResource; - -public final class DBResource { - private ResourceType type; - private String value; - - private DBResource() { - } - - Resource toThrift() { - return IResource.newBuilder( - type.getValue(), - type.getAuroraResourceConverter().parseFrom(value)); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResourceAggregate.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResourceAggregate.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResourceAggregate.java deleted file mode 100644 index 461d5c2..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBResourceAggregate.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import java.util.List; -import java.util.Set; - -import org.apache.aurora.GuavaUtils; -import org.apache.aurora.common.collections.Pair; -import org.apache.aurora.gen.ResourceAggregate; -import org.apache.aurora.scheduler.resources.ResourceType; -import org.apache.aurora.scheduler.storage.entities.IResource; -import org.apache.aurora.scheduler.storage.entities.IResourceAggregate; - -import static org.apache.aurora.GuavaUtils.toImmutableSet; - -public final class DBResourceAggregate { - private double numCpus; - private long ramMb; - private long diskMb; - private List<DBResource> resources; - - private DBResourceAggregate() { - } - - public ResourceAggregate toThrift() { - return new ResourceAggregate() - .setNumCpus(numCpus) - .setRamMb(ramMb) - .setDiskMb(diskMb) - .setResources(resources.stream().map(DBResource::toThrift).collect(toImmutableSet())); - } - - public static List<Pair<Integer, String>> pairsFromResources(Set<IResource> resources) { - return resources.stream() - .map(e -> Pair.of( - ResourceType.fromResource(e).getValue(), - ResourceType.fromResource(e).getAuroraResourceConverter().stringify(e.getRawValue()))) - .collect(GuavaUtils.toImmutableList()); - } - - public IResourceAggregate toImmutable() { - return IResourceAggregate.build(toThrift()); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBSaveQuota.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBSaveQuota.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBSaveQuota.java deleted file mode 100644 index 3d48592..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DBSaveQuota.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import org.apache.aurora.common.collections.Pair; -import org.apache.aurora.scheduler.storage.entities.IResourceAggregate; - -public final class DBSaveQuota { - private String role; - private DBResourceAggregate quota; - - private DBSaveQuota() { - } - - public Pair<String, IResourceAggregate> toImmutable() { - return Pair.of(role, quota.toImmutable()); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssginedPort.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssginedPort.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssginedPort.java deleted file mode 100644 index fdfff77..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssginedPort.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -public final class DbAssginedPort { - private String name; - private Integer port; - - private DbAssginedPort() { - } - - public Integer getPort() { - return port; - } - - public String getName() { - return name; - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssignedTask.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssignedTask.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssignedTask.java deleted file mode 100644 index cbc6a0c..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbAssignedTask.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import java.util.List; -import java.util.Map; - -import com.google.common.collect.Maps; - -import org.apache.aurora.gen.AssignedTask; - -public final class DbAssignedTask { - private String taskId; - private String slaveId; - private String slaveHost; - private DbTaskConfig task; - private List<DbAssginedPort> assignedPorts; - private int instanceId; - - private DbAssignedTask() { - } - - AssignedTask toThrift() { - Map<String, Integer> ports = Maps.newHashMap(); - for (DbAssginedPort port: assignedPorts) { - ports.put(port.getName(), port.getPort()); - } - - return new AssignedTask() - .setTaskId(taskId) - .setSlaveId(slaveId) - .setSlaveHost(slaveHost) - .setTask(task.toThrift()) - .setAssignedPorts(ports) - .setInstanceId(instanceId); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbConstraint.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbConstraint.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbConstraint.java deleted file mode 100644 index 9366757..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbConstraint.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import org.apache.aurora.gen.Constraint; - -public final class DbConstraint { - private String name; - private DbTaskConstraint constraint; - - private DbConstraint() { - } - - Constraint toThrift() { - return new Constraint() - .setName(name) - .setConstraint(constraint.toThrift()); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbContainer.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbContainer.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbContainer.java deleted file mode 100644 index 8d4d7ec..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbContainer.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import org.apache.aurora.gen.Container; -import org.apache.aurora.gen.DockerContainer; -import org.apache.aurora.gen.MesosContainer; - -public final class DbContainer { - private DockerContainer docker; - private DbImage image; - - private DbContainer() { - } - - Container toThrift() { - if (docker != null) { - return Container.docker(docker); - } - - if (image != null) { - return Container.mesos(new MesosContainer().setImage(image.toThrift())); - } - - return Container.mesos(new MesosContainer()); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbImage.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbImage.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbImage.java deleted file mode 100644 index 5964a2a..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbImage.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import org.apache.aurora.gen.AppcImage; -import org.apache.aurora.gen.DockerImage; -import org.apache.aurora.gen.Image; - -public final class DbImage { - private AppcImage appc; - private DockerImage docker; - - private DbImage() { - } - - Image toThrift() { - if (appc != null) { - return Image.appc(appc); - } - - if (docker != null) { - return Image.docker(docker); - } - - throw new IllegalStateException("Unknown image type."); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbInstanceTaskConfig.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbInstanceTaskConfig.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbInstanceTaskConfig.java deleted file mode 100644 index f3fd7a9..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbInstanceTaskConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import java.util.Set; - -import org.apache.aurora.gen.InstanceTaskConfig; -import org.apache.aurora.gen.Range; - -public final class DbInstanceTaskConfig { - private DbTaskConfig task; - private Set<Range> instances; - - private DbInstanceTaskConfig() { - } - - InstanceTaskConfig toThrift() { - return new InstanceTaskConfig() - .setTask(task.toThrift()) - .setInstances(instances); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobConfiguration.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobConfiguration.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobConfiguration.java deleted file mode 100644 index 40a5013..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobConfiguration.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import org.apache.aurora.gen.CronCollisionPolicy; -import org.apache.aurora.gen.Identity; -import org.apache.aurora.gen.JobConfiguration; -import org.apache.aurora.gen.JobKey; -import org.apache.aurora.scheduler.storage.entities.IJobConfiguration; - -public final class DbJobConfiguration { - private JobKey key; - private Identity owner; - private String cronSchedule; - private CronCollisionPolicy cronCollisionPolicy; - private DbTaskConfig taskConfig; - private int instanceCount; - - private DbJobConfiguration() { - } - - public IJobConfiguration toImmutable() { - return IJobConfiguration.build( - new JobConfiguration() - .setKey(key) - .setOwner(owner) - .setCronSchedule(cronSchedule) - .setCronCollisionPolicy(cronCollisionPolicy) - .setTaskConfig(taskConfig.toThrift()) - .setInstanceCount(instanceCount)); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdate.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdate.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdate.java deleted file mode 100644 index 78703e9..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdate.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import org.apache.aurora.gen.JobUpdate; -import org.apache.aurora.gen.JobUpdateSummary; -import org.apache.aurora.scheduler.storage.entities.IJobUpdate; - -public final class DbJobUpdate { - private JobUpdateSummary summary; - private DbJobUpdateInstructions instructions; - - private DbJobUpdate() { - } - - JobUpdate toThrift() { - return new JobUpdate() - .setSummary(summary) - .setInstructions(instructions.toThrift()); - } - - public IJobUpdate toImmutable() { - return IJobUpdate.build(toThrift()); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateDetails.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateDetails.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateDetails.java deleted file mode 100644 index 3a52724..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateDetails.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import java.util.List; - -import org.apache.aurora.gen.JobInstanceUpdateEvent; -import org.apache.aurora.gen.JobUpdateDetails; -import org.apache.aurora.gen.JobUpdateEvent; - -public final class DbJobUpdateDetails { - private DbJobUpdate update; - private List<JobUpdateEvent> updateEvents; - private List<JobInstanceUpdateEvent> instanceEvents; - - public JobUpdateDetails toThrift() { - return new JobUpdateDetails() - .setUpdate(update.toThrift()) - .setUpdateEvents(updateEvents) - .setInstanceEvents(instanceEvents); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateInstructions.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateInstructions.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateInstructions.java deleted file mode 100644 index d19aa85..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbJobUpdateInstructions.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import java.util.Set; - -import com.google.common.collect.FluentIterable; - -import org.apache.aurora.gen.JobUpdateInstructions; -import org.apache.aurora.gen.JobUpdateSettings; -import org.apache.aurora.scheduler.storage.entities.IJobUpdateInstructions; - -public final class DbJobUpdateInstructions { - private Set<DbInstanceTaskConfig> initialState; - private DbInstanceTaskConfig desiredState; - private JobUpdateSettings settings; - - private DbJobUpdateInstructions() { - } - - JobUpdateInstructions toThrift() { - return new JobUpdateInstructions() - .setInitialState( - FluentIterable.from(initialState) - .transform(DbInstanceTaskConfig::toThrift) - .toSet()) - .setDesiredState(desiredState == null ? null : desiredState.toThrift()) - .setSettings(settings); - } - - public IJobUpdateInstructions toImmutable() { - return IJobUpdateInstructions.build(toThrift()); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbScheduledTask.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbScheduledTask.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbScheduledTask.java deleted file mode 100644 index 6260923..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbScheduledTask.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import java.util.List; - -import com.google.common.collect.Ordering; -import com.google.common.primitives.Longs; - -import org.apache.aurora.gen.ScheduleStatus; -import org.apache.aurora.gen.ScheduledTask; -import org.apache.aurora.gen.TaskEvent; -import org.apache.aurora.scheduler.storage.entities.IScheduledTask; - -public final class DbScheduledTask { - private DbAssignedTask assignedTask; - private ScheduleStatus status; - private int failureCount; - private List<TaskEvent> taskEvents; - private String ancestorId; - - private DbScheduledTask() { - } - - public IScheduledTask toImmutable() { - return IScheduledTask.build( - new ScheduledTask() - .setAssignedTask(assignedTask.toThrift()) - .setStatus(status) - .setFailureCount(failureCount) - // Must be sorting a copy because taskEvents is populated by MyBatis and it might - // reuse the same instance. - .setTaskEvents(BY_TIMESTAMP.immutableSortedCopy(taskEvents)) - .setAncestorId(ancestorId)); - } - - private static final Ordering<TaskEvent> BY_TIMESTAMP = new Ordering<TaskEvent>() { - @Override - public int compare(TaskEvent left, TaskEvent right) { - return Longs.compare(left.getTimestamp(), right.getTimestamp()); - } - }; -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbStoredJobUpdateDetails.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbStoredJobUpdateDetails.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbStoredJobUpdateDetails.java deleted file mode 100644 index 8ec6d47..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbStoredJobUpdateDetails.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import org.apache.aurora.gen.storage.StoredJobUpdateDetails; - -public final class DbStoredJobUpdateDetails { - private DbJobUpdateDetails details; - private String lockToken; - - private DbStoredJobUpdateDetails() { - } - - public StoredJobUpdateDetails toThrift() { - return new StoredJobUpdateDetails() - .setDetails(details.toThrift()) - .setLockToken(lockToken); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConfig.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConfig.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConfig.java deleted file mode 100644 index 138cd53..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConfig.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import java.util.List; - -import com.google.common.collect.ImmutableSet; - -import org.apache.aurora.common.collections.Pair; -import org.apache.aurora.gen.Container; -import org.apache.aurora.gen.ExecutorConfig; -import org.apache.aurora.gen.Identity; -import org.apache.aurora.gen.JobKey; -import org.apache.aurora.gen.MesosContainer; -import org.apache.aurora.gen.MesosFetcherURI; -import org.apache.aurora.gen.Metadata; -import org.apache.aurora.gen.TaskConfig; -import org.apache.aurora.gen.Volume; -import org.apache.aurora.scheduler.storage.entities.ITaskConfig; - -import static org.apache.aurora.GuavaUtils.toImmutableSet; - -public final class DbTaskConfig { - private long rowId; - private JobKey job; - private Identity owner; - private boolean isService; - private double numCpus; - private long ramMb; - private long diskMb; - private int priority; - private int maxTaskFailures; - private boolean production; - private List<DbConstraint> constraints; - private List<String> requestedPorts; - private List<Pair<String, String>> taskLinks; - private String contactEmail; - private ExecutorConfig executorConfig; - private List<Metadata> metadata; - private List<MesosFetcherURI> mesosFetcherUris; - private DbContainer container; - private List<Volume> volumes; - private String tier; - private List<DBResource> resources; - - private DbTaskConfig() { - } - - public long getRowId() { - return rowId; - } - - TaskConfig toThrift() { - TaskConfig builder = new TaskConfig() - .setJob(job) - .setOwner(owner) - .setIsService(isService) - .setNumCpus(numCpus) - .setRamMb(ramMb) - .setDiskMb(diskMb) - .setPriority(priority) - .setMaxTaskFailures(maxTaskFailures) - .setProduction(production) - .setTier(tier) - .setConstraints(constraints.stream() - .map(DbConstraint::toThrift) - .collect(toImmutableSet())) - .setRequestedPorts(ImmutableSet.copyOf(requestedPorts)) - .setTaskLinks(Pairs.toMap(taskLinks)) - .setContactEmail(contactEmail) - .setExecutorConfig(executorConfig) - .setMetadata(ImmutableSet.copyOf(metadata)) - .setMesosFetcherUris(ImmutableSet.copyOf(mesosFetcherUris)) - .setContainer( - container == null ? Container.mesos(new MesosContainer()) : container.toThrift()) - .setResources(resources.stream().map(DBResource::toThrift).collect(toImmutableSet())); - - // In the DB Layer volumes are associated with a task config, since containers are not - // modelled as tables. - if (builder.getContainer().isSetMesos()) { - builder.getContainer().getMesos().setVolumes(volumes); - } - - return builder; - } - - public ITaskConfig toImmutable() { - return ITaskConfig.build(toThrift()); - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConstraint.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConstraint.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConstraint.java deleted file mode 100644 index e3e1b7a..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/DbTaskConstraint.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import javax.annotation.Nullable; - -import org.apache.aurora.gen.LimitConstraint; -import org.apache.aurora.gen.TaskConstraint; -import org.apache.aurora.gen.ValueConstraint; - -public final class DbTaskConstraint { - private ValueConstraint value; - private LimitConstraint limit; - - private DbTaskConstraint() { - } - - private static boolean isSet(Object o) { - return o != null; - } - - @Nullable - TaskConstraint toThrift() { - // Using the isSet shim to work around a well-intentioned PMD rule that prefers positive - // branching (would trip if we did value != null directly here. - if (isSet(value)) { - return TaskConstraint.value(value); - } else if (isSet(limit)) { - return TaskConstraint.limit(limit); - } else { - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/LockRow.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/LockRow.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/LockRow.java deleted file mode 100644 index aaa0a68..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/LockRow.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import org.apache.aurora.gen.JobKey; -import org.apache.aurora.gen.Lock; -import org.apache.aurora.gen.LockKey; - -/** - * The union of {@link Lock} and {@link JobKey}. This class is required because the generated - * thrift code for {@code union} fields is incompatible with the mapping behaviour of MyBatis. - * This class works around this incompatibility by explicitly initialising an empty lock with - * the union field set to an empty {@link JobKey} instance and exposing a getter method for MyBatis. - * Note that this only works because the {@link LockKey} is a union of exactly one type. If LockKey - * is modified to support more types, we will need to rework this design. - * - * TODO(davmclau): - * These intermediate classes for resolving relationships on Thrift union types should be - * auto-generated, as the logic will be identical in each one. The generated code needs to allow - * for exactly one field in the union to be set, returning null when the getter for the field - * is called the first time. - */ -public class LockRow { - private final Lock lock = new Lock(); - - public LockRow() { - LockKey lockKey = new LockKey(); - lock.setKey(lockKey); - lockKey.setJob(new JobKey()); - } - - public Lock getLock() { - return lock; - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/main/java/org/apache/aurora/scheduler/storage/db/views/MigrationChangelogEntry.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/views/MigrationChangelogEntry.java b/src/main/java/org/apache/aurora/scheduler/storage/db/views/MigrationChangelogEntry.java deleted file mode 100644 index 6159af6..0000000 --- a/src/main/java/org/apache/aurora/scheduler/storage/db/views/MigrationChangelogEntry.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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 org.apache.aurora.scheduler.storage.db.views; - -import java.util.Arrays; - -import com.google.common.base.Charsets; -import com.google.common.base.Objects; - -import org.apache.ibatis.migration.Change; - -public class MigrationChangelogEntry extends Change { - private byte[] downgradeScript; - - public String getDowngradeScript() { - return new String(downgradeScript, Charsets.UTF_8); - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof MigrationChangelogEntry)) { - return false; - } - - if (!super.equals(o)) { - return false; - } - - MigrationChangelogEntry other = (MigrationChangelogEntry) o; - return Arrays.equals(downgradeScript, other.downgradeScript); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), downgradeScript); - } -}
