Search in sources :

Example 11 with Variable

use of org.apache.mesos.state.Variable in project jesos by groupon.

the class AbstractTestState method testExpungeNonExistentValue.

@Test
public void testExpungeNonExistentValue() throws Exception {
    final State state = getState();
    final Variable empty = state.fetch("does-not-exist").get();
    assertNotNull(empty);
    assertTrue(empty.value().length == 0);
    final boolean expunged = state.expunge(empty).get();
    assertFalse(expunged);
}
Also used : Variable(org.apache.mesos.state.Variable) State(org.apache.mesos.state.State) Test(org.junit.Test)

Example 12 with Variable

use of org.apache.mesos.state.Variable in project jesos by groupon.

the class AbstractTestState method testSetAndGet.

@Test
public void testSetAndGet() throws Exception {
    final State state = getState();
    final byte[] value = "The quick brown fox jumps over the lazy dog.".getBytes(StandardCharsets.UTF_8);
    final Variable var = state.fetch("someValue").get();
    assertTrue(var.value().length == 0);
    final Variable newVar = var.mutate(value);
    final JVariable storedVar = (JVariable) state.store(newVar).get();
    assertNotNull(storedVar);
    final JVariable retrievedVar = (JVariable) state.fetch("someValue").get();
    assertNotNull(retrievedVar);
    assertArrayEquals(newVar.value(), retrievedVar.value());
    assertArrayEquals(storedVar.value(), retrievedVar.value());
    assertEquals(storedVar.getName(), retrievedVar.getName());
    assertEquals(storedVar.getUuid(), retrievedVar.getUuid());
}
Also used : Variable(org.apache.mesos.state.Variable) State(org.apache.mesos.state.State) Test(org.junit.Test)

Example 13 with Variable

use of org.apache.mesos.state.Variable in project jesos by groupon.

the class TestJVariable method testMutate.

@Test
public void testMutate() {
    final String name = "test-name";
    final byte[] value = "The quick brown fox jumps over the lazy dog.".getBytes(StandardCharsets.UTF_8);
    final byte[] newValue = "Ich esse Autos zum Abendbrot und mache Kopfsprung ins Sandbecken. Gruen. Rot. Pferderennen.".getBytes(StandardCharsets.UTF_8);
    final JVariable v = new JVariable(name, value);
    final Variable w = v.mutate(newValue);
    assertEquals(JVariable.class, w.getClass());
    assertArrayEquals(newValue, w.value());
    assertEquals(name, v.getName());
    assertArrayEquals(value, v.value());
    final JVariable v2 = (JVariable) w;
    assertEquals(v.getName(), v2.getName());
    assertEquals(v.getUuid(), v2.getUuid());
}
Also used : Variable(org.apache.mesos.state.Variable) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

Variable (org.apache.mesos.state.Variable)13 State (org.apache.mesos.state.State)11 Test (org.junit.Test)11 ImmutableList (com.google.common.collect.ImmutableList)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)2 Callable (java.util.concurrent.Callable)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 ByteString (com.google.protobuf.ByteString)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 NotNull (javax.validation.constraints.NotNull)1 InMemoryState (org.apache.mesos.state.InMemoryState)1 WriteBatch (org.iq80.leveldb.WriteBatch)1 WriteOptions (org.iq80.leveldb.WriteOptions)1 Iq80DBFactory.asString (org.iq80.leveldb.impl.Iq80DBFactory.asString)1