Search in sources :

Example 26 with Container

use of net.minecraft.server.v1_10_R1.Container in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method setItem.

@Override
public void setItem(int index, ItemStack item) {
    // Instead of updating one container, update all the containers
    // That are looking at the table, basically the viewers
    items[index] = item;
    for (Container container : containers) {
        container.a(this);
    }
    // Update the armorstand grid
    display.update();
}
Also used : Container(net.minecraft.server.v1_9_R2.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_9_R2.ContainerManager_v1_9_R2.SelfContainer)

Example 27 with Container

use of net.minecraft.server.v1_10_R1.Container in project tests by datanucleus.

the class BasicTest method testInh2.

public void testInh2() {
    try {
        PersistenceManager pm = pmf.getPersistenceManager();
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            Base base1 = new Base(1, "b1");
            Base base2 = new Base(2, "b2");
            Base base3 = new Base(3, "b3");
            SubBase group1 = new SubBase(4, "b4", "SB1");
            SubBase group2 = new SubBase(5, "b5", "SB2");
            Container c = new Container(new Base[] { base1, base2, base3, group1, group2 });
            pm.makePersistent(c);
            tx.commit();
            tx.begin();
            Collection col = (Collection) pm.newQuery(SubBase.class).execute();
            assertTrue(col.size() == 2);
            assertTrue(col.contains(group1));
            assertTrue(col.contains(group2));
            tx.commit();
        } finally {
            if (tx.isActive()) {
                tx.rollback();
            }
            pm.close();
        }
    } finally {
        clean(Container.class);
        clean(SubBase.class);
        clean(Base.class);
    }
}
Also used : SubBase(org.datanucleus.samples.metadata.inh2.SubBase) Container(org.datanucleus.samples.metadata.inh2.Container) Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager) Collection(java.util.Collection) Base(org.datanucleus.samples.metadata.inh2.Base) SubBase(org.datanucleus.samples.metadata.inh2.SubBase)

Example 28 with Container

use of net.minecraft.server.v1_10_R1.Container in project flytekit-java by flyteorg.

the class ProjectClosureTest method testCreateTaskTemplateForRunnableTaskWithResources.

@Test
public void testCreateTaskTemplateForRunnableTaskWithResources() {
    // given
    Map<Resources.ResourceName, String> resourceValues = new HashMap<>();
    resourceValues.put(Resources.ResourceName.MEMORY, "0.5Gi");
    Resources expectedResources = Resources.builder().limits(resourceValues).requests(resourceValues).build();
    RunnableTask task = createRunnableTask(expectedResources);
    String image = "my-image";
    // when
    TaskTemplate result = ProjectClosure.createTaskTemplateForRunnableTask(task, image);
    // then
    Container container = result.container();
    assertNotNull(container);
    assertThat(container.image(), equalTo(image));
    assertThat(container.resources(), equalTo(expectedResources));
    assertThat(result.interface_(), equalTo(TypedInterface.builder().inputs(SdkTypes.nulls().getVariableMap()).outputs(SdkTypes.nulls().getVariableMap()).build()));
    assertThat(result.custom(), equalTo(Struct.of(emptyMap())));
    assertThat(result.retries(), equalTo(RetryStrategy.builder().retries(0).build()));
    assertThat(result.type(), equalTo("java-task"));
}
Also used : TaskTemplate(org.flyte.api.v1.TaskTemplate) Container(org.flyte.api.v1.Container) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) Resources(org.flyte.api.v1.Resources) RunnableTask(org.flyte.api.v1.RunnableTask) Test(org.junit.jupiter.api.Test)

Example 29 with Container

use of net.minecraft.server.v1_10_R1.Container in project flytekit-java by flyteorg.

the class ProtoUtilTest method shouldSerDeTaskTemplate.

@Test
void shouldSerDeTaskTemplate() {
    Container container = Container.builder().command(ImmutableList.of("echo")).args(ImmutableList.of("hello world")).env(ImmutableList.of(KeyValuePair.of("key", "value"))).image("alpine:3.7").build();
    Variable stringVar = ApiUtils.createVar(SimpleType.STRING);
    Variable integerVar = ApiUtils.createVar(SimpleType.INTEGER);
    TypedInterface interface_ = TypedInterface.builder().inputs(ImmutableMap.of("x", stringVar)).outputs(ImmutableMap.of("y", integerVar)).build();
    RetryStrategy retries = RetryStrategy.builder().retries(4).build();
    TaskTemplate template = TaskTemplate.builder().container(container).type("custom-task").interface_(interface_).retries(retries).custom(Struct.of(ImmutableMap.of("custom-prop", Struct.Value.ofStringValue("custom-value")))).build();
    Tasks.TaskTemplate templateProto = Tasks.TaskTemplate.newBuilder().setContainer(Tasks.Container.newBuilder().setImage("alpine:3.7").addCommand("echo").addArgs("hello world").addEnv(Literals.KeyValuePair.newBuilder().setKey("key").setValue("value").build()).build()).setMetadata(Tasks.TaskMetadata.newBuilder().setRuntime(Tasks.RuntimeMetadata.newBuilder().setType(Tasks.RuntimeMetadata.RuntimeType.FLYTE_SDK).setFlavor(ProtoUtil.RUNTIME_FLAVOR).setVersion(ProtoUtil.RUNTIME_VERSION).build()).setRetries(Literals.RetryStrategy.newBuilder().setRetries(4).build()).build()).setInterface(Interface.TypedInterface.newBuilder().setInputs(Interface.VariableMap.newBuilder().putVariables("x", Interface.Variable.newBuilder().setType(Types.LiteralType.newBuilder().setSimple(Types.SimpleType.STRING).build()).build()).build()).setOutputs(Interface.VariableMap.newBuilder().putVariables("y", Interface.Variable.newBuilder().setType(Types.LiteralType.newBuilder().setSimple(Types.SimpleType.INTEGER).build()).build()).build()).build()).setType("custom-task").setCustom(com.google.protobuf.Struct.newBuilder().putFields("custom-prop", Value.newBuilder().setStringValue("custom-value").build()).build()).build();
    Tasks.TaskTemplate serializedTemplate = ProtoUtil.serialize(template);
    TaskTemplate deserializedTemplate = ProtoUtil.deserialize(templateProto);
    assertThat(serializedTemplate, equalTo(templateProto));
    assertThat(deserializedTemplate, equalTo(template));
}
Also used : TaskTemplate(org.flyte.api.v1.TaskTemplate) TypedInterface(org.flyte.api.v1.TypedInterface) Container(org.flyte.api.v1.Container) Variable(org.flyte.api.v1.Variable) Tasks(flyteidl.core.Tasks) RetryStrategy(org.flyte.api.v1.RetryStrategy) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 30 with Container

use of net.minecraft.server.v1_10_R1.Container in project flytekit-java by flyteorg.

the class ProtoUtilTest method shouldRejectResourcesWithInvalidQuantities.

@ParameterizedTest
@ValueSource(strings = { "", "1.1.", "+-1", "2+2", "Ki", "1Qi", "-1", "-5G" })
void shouldRejectResourcesWithInvalidQuantities(String quantity) {
    Container container = createContainer(Resources.builder().requests(ImmutableMap.of(Resources.ResourceName.CPU, quantity)).build());
    IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> ProtoUtil.serialize(container));
    assertEquals("Resource requests [CPU] has invalid quantity: " + quantity, exception.getMessage());
}
Also used : Container(org.flyte.api.v1.Container) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Container (org.flyte.api.v1.Container)9 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 Tasks (flyteidl.core.Tasks)4 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_11_R1.ContainerManager_v1_11_R1.SelfContainer)4 ArrayList (java.util.ArrayList)4 App (mesosphere.marathon.client.model.v2.App)4 Container (mesosphere.marathon.client.model.v2.Container)4 Docker (mesosphere.marathon.client.model.v2.Docker)4 HealthCheck (mesosphere.marathon.client.model.v2.HealthCheck)4 Container (net.minecraft.server.v1_11_R1.Container)4 Container (net.minecraft.server.v1_12_R1.Container)4 Container (net.minecraft.server.v1_16_R3.Container)4 Container (net.minecraft.server.v1_8_R3.Container)4 TaskTemplate (org.flyte.api.v1.TaskTemplate)4 Test (org.junit.jupiter.api.Test)4 Container (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container)4 ContainerBuilder (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.ContainerBuilder)4 TileEntityContainer (com.bgsoftware.wildchests.objects.containers.TileEntityContainer)3 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_10_R1.ContainerManager_v1_10_R1.SelfContainer)3