Search in sources :

Example 1 with ComplexTObject

use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.

the class Manager method createUser.

/**
 * Create a user with the specified {@code username}, {@code password} and
 * {@code role}.
 *
 * @param username
 * @param password
 * @param role
 */
public void createUser(String username, String password, String role) {
    ByteBuffer uname = ByteBuffers.fromUtf8String(username);
    ByteBuffer pword = ByteBuffers.fromUtf8String(password);
    List<ComplexTObject> params = ImmutableList.of(ComplexTObject.fromJavaObject(uname), ComplexTObject.fromJavaObject(pword), ComplexTObject.fromJavaObject(role));
    concourse.execute(() -> concourse.$core().invokeManagement("createUser", params, concourse.creds()));
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) ByteBuffer(java.nio.ByteBuffer)

Example 2 with ComplexTObject

use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.

the class Manager method grant.

/**
 * Grant the {@code permission} to the user with {@code username} in the
 * specified {@code environment}.
 *
 * @param username
 * @param permission
 * @param environment
 */
public void grant(String username, String permission, String environment) {
    ByteBuffer uname = ByteBuffers.fromUtf8String(username);
    List<ComplexTObject> params = ImmutableList.of(ComplexTObject.fromJavaObject(uname), ComplexTObject.fromJavaObject(permission), ComplexTObject.fromJavaObject(environment));
    concourse.execute(() -> concourse.$core().invokeManagement("grant", params, concourse.creds()));
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) ByteBuffer(java.nio.ByteBuffer)

Example 3 with ComplexTObject

use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.

the class LazyTrackingTObjectResultDatasetTest method testSerializationRepro.

@Test
public void testSerializationRepro() {
    String json = FileOps.read(Resources.getAbsolutePath("/data.json"));
    List<Multimap<String, Object>> objects = Convert.anyJsonToJava(json);
    for (Multimap<String, Object> object : objects) {
        long entity = Time.now();
        for (Entry<String, Collection<Object>> entry : object.asMap().entrySet()) {
            String attribute = entry.getKey();
            for (Object value : entry.getValue()) {
                dataset.insert(entity, attribute, Convert.javaToThrift(value));
            }
        }
    }
    PluginSerializer serializer = new PluginSerializer();
    ByteBuffer bytes = serializer.serialize(dataset);
    ComplexTObject complex = ComplexTObject.fromJavaObject(bytes);
    ByteBuffer bytes2 = complex.getJavaObject();
    Object obj = serializer.deserialize(bytes2);
    Assert.assertEquals(dataset, obj);
}
Also used : Multimap(com.google.common.collect.Multimap) ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) Collection(java.util.Collection) ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) PluginSerializer(com.cinchapi.concourse.server.plugin.io.PluginSerializer) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 4 with ComplexTObject

use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.

the class ObjectResultDatasetTest method testSerialization.

@Test
public void testSerialization() {
    ObjectResultDataset dataset = new ObjectResultDataset(new TObjectResultDataset());
    dataset.insert(1L, "name", "Jeff Nelson");
    PluginSerializer serializer = new PluginSerializer();
    ByteBuffer bytes = serializer.serialize(dataset);
    ComplexTObject complex = ComplexTObject.fromJavaObject(bytes);
    ByteBuffer bytes2 = complex.getJavaObject();
    Object obj = serializer.deserialize(bytes2);
    Assert.assertEquals(dataset, obj);
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) PluginSerializer(com.cinchapi.concourse.server.plugin.io.PluginSerializer) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 5 with ComplexTObject

use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.

the class PluginSerializerTest method testSerializeComplexTObject.

@Test
public void testSerializeComplexTObject() {
    int count = Random.getScaleCount();
    List<TObject> list = Lists.newArrayListWithCapacity(count);
    for (int i = 0; i < count; ++i) {
        list.add(Convert.javaToThrift(Random.getObject()));
    }
    ComplexTObject expected = ComplexTObject.fromJavaObject(list);
    ByteBuffer buffer = serializer.serialize(expected);
    ComplexTObject actual = serializer.deserialize(buffer);
    Assert.assertEquals(expected, actual);
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)14 ByteBuffer (java.nio.ByteBuffer)10 TObject (com.cinchapi.concourse.thrift.TObject)7 Test (org.junit.Test)6 PluginSerializer (com.cinchapi.concourse.server.plugin.io.PluginSerializer)4 Map (java.util.Map)3 RemoteMessage (com.cinchapi.concourse.server.plugin.RemoteMessage)2 Convert (com.cinchapi.concourse.util.Convert)2 Multimap (com.google.common.collect.Multimap)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 Order (com.cinchapi.concourse.lang.sort.Order)1 ClientInvokable (com.cinchapi.concourse.server.management.ClientInvokable)1 InsufficientAtomicityException (com.cinchapi.concourse.server.ops.InsufficientAtomicityException)1 PluginRestricted (com.cinchapi.concourse.server.plugin.PluginRestricted)1 ObjectResultDataset (com.cinchapi.concourse.server.plugin.data.ObjectResultDataset)1 TObjectResultDataset (com.cinchapi.concourse.server.plugin.data.TObjectResultDataset)1 PluginSerializable (com.cinchapi.concourse.server.plugin.io.PluginSerializable)1 AtomicStateException (com.cinchapi.concourse.server.storage.AtomicStateException)1