Search in sources :

Example 1 with RoundRobinPolicy

use of alluxio.client.block.policy.RoundRobinPolicy in project alluxio by Alluxio.

the class OutStreamOptionsTest method fields.

/**
 * Tests getting and setting fields.
 */
@Test
public void fields() throws Exception {
    Random random = new Random();
    long blockSize = random.nextLong();
    BlockLocationPolicy locationPolicy = new RoundRobinPolicy(mConf);
    String owner = CommonUtils.randomAlphaNumString(10);
    String group = CommonUtils.randomAlphaNumString(10);
    Mode mode = new Mode((short) random.nextInt());
    int ttl = 5;
    TtlAction ttlAction = TtlAction.FREE;
    int writeTier = random.nextInt();
    WriteType writeType = WriteType.NONE;
    mConf.set(PropertyKey.USER_FILE_CREATE_TTL, ttl);
    mConf.set(PropertyKey.USER_FILE_CREATE_TTL_ACTION, ttlAction);
    ClientContext clientContext = ClientContext.create(mConf);
    OutStreamOptions options = OutStreamOptions.defaults(clientContext);
    options.setBlockSizeBytes(blockSize);
    options.setLocationPolicy(locationPolicy);
    options.setOwner(owner);
    options.setGroup(group);
    options.setMode(mode);
    options.setWriteTier(writeTier);
    options.setWriteType(writeType);
    assertEquals(blockSize, options.getBlockSizeBytes());
    assertEquals(locationPolicy, options.getLocationPolicy());
    assertEquals(owner, options.getOwner());
    assertEquals(group, options.getGroup());
    assertEquals(mode, options.getMode());
    assertEquals(ttl, options.getCommonOptions().getTtl());
    assertEquals(ttlAction, options.getCommonOptions().getTtlAction());
    assertEquals(writeTier, options.getWriteTier());
    assertEquals(writeType.getAlluxioStorageType(), options.getAlluxioStorageType());
    assertEquals(writeType.getUnderStorageType(), options.getUnderStorageType());
}
Also used : TtlAction(alluxio.grpc.TtlAction) Random(java.util.Random) WriteType(alluxio.client.WriteType) Mode(alluxio.security.authorization.Mode) ClientContext(alluxio.ClientContext) BlockLocationPolicy(alluxio.client.block.policy.BlockLocationPolicy) RoundRobinPolicy(alluxio.client.block.policy.RoundRobinPolicy) Test(org.junit.Test)

Aggregations

ClientContext (alluxio.ClientContext)1 WriteType (alluxio.client.WriteType)1 BlockLocationPolicy (alluxio.client.block.policy.BlockLocationPolicy)1 RoundRobinPolicy (alluxio.client.block.policy.RoundRobinPolicy)1 TtlAction (alluxio.grpc.TtlAction)1 Mode (alluxio.security.authorization.Mode)1 Random (java.util.Random)1 Test (org.junit.Test)1