List of usage examples for org.apache.hadoop.conf Configuration setClass
public void setClass(String name, Class<?> theClass, Class<?> xface)
name
property to the name of a theClass
implementing the given interface xface
. From source file:com.cloudera.hadoop.hdfs.nfs.nfs4.TestWritableFileFileHandleStore.java
License:Apache License
@Test public void testWrite() throws Exception { Configuration conf = new Configuration(); conf.setClass(NFS_FILEHANDLE_STORE_CLASS, WritableFileFileHandleStore.class, FileHandleStore.class); File file = new File("/tmp/" + UUID.randomUUID().toString()); file.delete();/*from www. j av a2 s . com*/ conf.set(NFS_FILEHANDLE_STORE_FILE, file.getAbsolutePath()); WritableFileFileHandleStore store = (WritableFileFileHandleStore) FileHandleStore.get(conf); assertTrue(store.getAll().isEmpty()); long inode = System.currentTimeMillis(); byte[] fileHandle = String.valueOf(inode).getBytes(); String name = String.valueOf(inode); FileHandleStoreEntry entry = new FileHandleStoreEntry(fileHandle, name, inode); store.storeFileHandle(entry); assertTrue(store.getAll().size() == 1); entry = store.getAll().get(0); assertTrue(entry.fileID == inode); assertTrue(Arrays.equals(fileHandle, entry.fileHandle)); assertEquals(name, entry.path); store.close(); store = (WritableFileFileHandleStore) FileHandleStore.get(conf); assertTrue(store.getAll().size() == 1); entry = store.getAll().get(0); assertTrue(entry.fileID == inode); assertTrue(Arrays.equals(fileHandle, entry.fileHandle)); assertEquals(name, entry.path); store.close(); file.delete(); }
From source file:com.cloudera.llama.am.api.TestLlamaAM.java
License:Apache License
@Test public void testCreate() throws Exception { Configuration conf = new Configuration(false); conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class); testCreate(conf);//from w w w . j a v a 2 s . c o m }
From source file:com.cloudera.llama.am.impl.TestExpansionReservationsLlamaAM.java
License:Apache License
@Test public void testReleaseReservationWithExpansionMultipleClients() throws Exception { Configuration conf = new Configuration(false); conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, RecordingMockRMConnector.class, RMConnector.class); conf.setBoolean(LlamaAM.NORMALIZING_ENABLED_KEY, false); conf.setBoolean(LlamaAM.CACHING_ENABLED_KEY, false); SingleQueueLlamaAM am = new SingleQueueLlamaAM(conf, "queue", Executors.newScheduledThreadPool(4)); am.setCallback(new DummySingleQueueLlamaAMCallback()); ExpansionReservationsLlamaAM eAm = new ExpansionReservationsLlamaAM(am); try {//from w w w . jav a 2 s. c om eAm.start(); Reservation r = TestUtils.createReservation(true); PlacedReservation pr = TestUtils.createPlacedReservation(r, PlacedReservation.Status.ALLOCATED); eAm.reserve(pr.getReservationId(), r); UUID resource1Id = pr.getPlacedResources().get(0).getResourceId(); RMEvent change = RMEvent.createStatusChangeEvent(resource1Id, PlacedResource.Status.ALLOCATED); am.onEvent(Arrays.asList(change)); Expansion e1 = TestUtils.createExpansion(pr); UUID eId1 = eAm.expand(e1); Assert.assertNotNull(eId1); Assert.assertEquals(new HashSet<UUID>(Arrays.asList(eId1)), eAm.getExpansions(pr.getReservationId())); Expansion e2 = TestUtils.createExpansion(pr); UUID eId2 = eAm.expand(e2); Assert.assertNotNull(eId2); Assert.assertEquals(new HashSet<UUID>(Arrays.asList(eId1, eId2)), eAm.getExpansions(pr.getReservationId())); eAm.releaseReservation(pr.getHandle(), pr.getReservationId(), false); Assert.assertNull(eAm.getExpansions(pr.getReservationId())); } finally { eAm.stop(); } }
From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java
License:Apache License
@Test public void testMultiQueueDelegation() throws Exception { Configuration conf = new Configuration(false); conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class); multiQueueTestImpl(conf);/*from w ww . j av a 2 s. c om*/ }
From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java
License:Apache License
@Test public void testMultiQueueDelegationWithoutThrottling() throws Exception { Configuration conf = new Configuration(false); conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class); conf.setBoolean(LlamaAM.THROTTLING_ENABLED_KEY, false); multiQueueTestImpl(conf);/* www .j a va 2s . c om*/ }
From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java
License:Apache License
@Test(expected = LlamaException.class) public void testReleaseReservationForClientException() throws Exception { Configuration conf = new Configuration(false); conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class); conf.setBoolean("fail.release", true); LlamaAM am = LlamaAM.create(conf);/*from w ww .j a v a 2 s . c o m*/ try { am.start(); UUID cId = UUID.randomUUID(); am.reserve(TestUtils.createReservation(cId, "q", 1, true)); am.releaseReservationsForHandle(cId, false); } finally { am.stop(); } }
From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java
License:Apache License
@Test(expected = LlamaException.class) public void testReleaseReservationForClientDiffQueuesException() throws Exception { Configuration conf = new Configuration(false); conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class); conf.setBoolean("fail.release", true); LlamaAM am = LlamaAM.create(conf);//from w ww .j a v a2 s .c o m try { am.start(); UUID cId = UUID.randomUUID(); am.reserve(TestUtils.createReservation(cId, "q1", 1, true)); am.reserve(TestUtils.createReservation(cId, "q2", 1, true)); am.releaseReservationsForHandle(cId, false); } finally { am.stop(); } }
From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java
License:Apache License
@Test(expected = LlamaException.class) public void testStartOfDelegatedLlamaAmFail() throws Exception { Configuration conf = new Configuration(false); conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class); conf.setBoolean("fail.start", true); conf.set(LlamaAM.CORE_QUEUES_KEY, "q"); LlamaAM am = LlamaAM.create(conf);/*w w w . j a va2 s.co m*/ am.start(); }
From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java
License:Apache License
@Test(expected = LlamaException.class) public void testRegisterOfDelegatedLlamaAmFail() throws Exception { Configuration conf = new Configuration(false); conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class); conf.setBoolean("fail.register", true); conf.set(LlamaAM.CORE_QUEUES_KEY, "q"); LlamaAM am = LlamaAM.create(conf);/* w ww . j a v a2 s . c o m*/ am.start(); }
From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java
License:Apache License
@Test public void testGetReservationUnknown() throws Exception { Configuration conf = new Configuration(false); conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class); LlamaAM am = LlamaAM.create(conf);//from www. jav a 2s . co m am.start(); Assert.assertNull(am.getReservation(UUID.randomUUID())); }