use of com.mesosphere.sdk.offer.taskdata.TaskLabelWriter in project dcos-commons by mesosphere.
the class StateStoreUtilsTest method newTaskInfo.
private static Protos.TaskInfo newTaskInfo(final String taskName, final ConfigStore<ServiceSpec> configStore) throws ConfigStoreException {
Protos.TaskInfo.Builder taskInfoBuilder = newTaskInfo(taskName).toBuilder();
// POD type
final UUID targetConfig = configStore.getTargetConfig();
final int podIndex = 0;
final String podType = configStore.fetch(targetConfig).getPods().get(podIndex).getType();
// create default labels:
taskInfoBuilder.setLabels(new TaskLabelWriter(taskInfoBuilder).setTargetConfiguration(targetConfig).setType(podType).setIndex(podIndex).toProto());
return taskInfoBuilder.build();
}
use of com.mesosphere.sdk.offer.taskdata.TaskLabelWriter in project dcos-commons by mesosphere.
the class PersistentLaunchRecorderTest method testUpdateResourcesNoSharedTasksInStateStore.
@Test
public void testUpdateResourcesNoSharedTasksInStateStore() throws TaskException {
Protos.Resource targetResource = Protos.Resource.newBuilder().setName("cpus").setType(Protos.Value.Type.SCALAR).setScalar(Protos.Value.Scalar.newBuilder().setValue(1.0)).build();
String taskName = "pod-0-init";
Protos.TaskInfo taskInfo = baseTaskInfo.toBuilder().setLabels(new TaskLabelWriter(baseTaskInfo).setType("pod").setIndex(0).toProto()).setName(taskName).addAllResources(Arrays.asList(targetResource)).build();
stateStore.storeTasks(Arrays.asList(taskInfo));
Assert.assertEquals(1, stateStore.fetchTaskNames().size());
persistentLaunchRecorder.updateTaskResourcesWithinResourceSet(persistentLaunchRecorder.getPodInstance(taskInfo).get(), taskInfo);
Assert.assertEquals(1, stateStore.fetchTaskNames().size());
Assert.assertEquals(targetResource, stateStore.fetchTask(taskName).get().getResources(0));
}
use of com.mesosphere.sdk.offer.taskdata.TaskLabelWriter in project dcos-commons by mesosphere.
the class TaskUtilsTest method buildTask.
private static Protos.TaskInfo buildTask(ConfigStore<ServiceSpec> configStore, int index, String task) {
Protos.TaskInfo.Builder taskBuilder = Protos.TaskInfo.newBuilder().setTaskId(TestConstants.TASK_ID).setSlaveId(TestConstants.AGENT_ID).setName(String.format("server-%d-%s", index, task));
UUID id;
try {
id = configStore.getTargetConfig();
} catch (ConfigStoreException e) {
throw new IllegalStateException(e);
}
taskBuilder.setLabels(new TaskLabelWriter(taskBuilder).setIndex(index).setType("server").setTargetConfiguration(id).toProto());
return taskBuilder.build();
}
use of com.mesosphere.sdk.offer.taskdata.TaskLabelWriter in project dcos-commons by mesosphere.
the class RoundRobinByHostnameRuleTest method getTaskInfo.
private static TaskInfo getTaskInfo(String name, String host) {
TaskInfo.Builder infoBuilder = TaskTestUtils.getTaskInfo(Collections.emptyList()).toBuilder().setName(name).setTaskId(CommonIdUtils.toTaskId(TestConstants.SERVICE_NAME, name));
infoBuilder.setLabels(new TaskLabelWriter(infoBuilder).setHostname(offerWithHost(host)).toProto());
return infoBuilder.build();
}
use of com.mesosphere.sdk.offer.taskdata.TaskLabelWriter in project dcos-commons by mesosphere.
the class TaskTypeRuleTest method getTask.
private static TaskInfo getTask(String type, String id, String agent) {
TaskInfo.Builder taskBuilder = TaskTestUtils.getTaskInfo(Collections.emptyList()).toBuilder();
taskBuilder.getTaskIdBuilder().setValue(id);
try {
taskBuilder.setName(CommonIdUtils.toTaskName(taskBuilder.getTaskId()));
} catch (Exception e) {
throw new IllegalStateException(e);
}
taskBuilder.getSlaveIdBuilder().setValue(agent);
taskBuilder.setLabels(new TaskLabelWriter(taskBuilder).setType(type).toProto());
return taskBuilder.build();
}
Aggregations