use of org.apache.twill.filesystem.LocationFactory in project cdap by caskdata.
the class BaseHiveExploreServiceTest method initialize.
protected static void initialize(CConfiguration cConf, TemporaryFolder tmpFolder, boolean useStandalone, boolean enableAuthorization) throws Exception {
if (!runBefore) {
return;
}
Configuration hConf = new Configuration();
if (enableAuthorization) {
LocationFactory locationFactory = new LocalLocationFactory(tmpFolder.newFolder());
Location authExtensionJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class);
cConf.setBoolean(Constants.Security.ENABLED, true);
cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, authExtensionJar.toURI().getPath());
cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 0);
}
List<Module> modules = useStandalone ? createStandaloneModules(cConf, hConf, tmpFolder) : createInMemoryModules(cConf, hConf, tmpFolder);
injector = Guice.createInjector(modules);
transactionManager = injector.getInstance(TransactionManager.class);
transactionManager.startAndWait();
transactionSystemClient = injector.getInstance(TransactionSystemClient.class);
dsOpService = injector.getInstance(DatasetOpExecutor.class);
dsOpService.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
exploreExecutorService = injector.getInstance(ExploreExecutorService.class);
exploreExecutorService.startAndWait();
datasetFramework = injector.getInstance(DatasetFramework.class);
exploreClient = injector.getInstance(DiscoveryExploreClient.class);
exploreService = injector.getInstance(ExploreService.class);
exploreClient.ping();
notificationService = injector.getInstance(NotificationService.class);
notificationService.startAndWait();
streamService = injector.getInstance(StreamService.class);
streamService.startAndWait();
streamHttpService = injector.getInstance(StreamHttpService.class);
streamHttpService.startAndWait();
exploreTableManager = injector.getInstance(ExploreTableManager.class);
streamAdmin = injector.getInstance(StreamAdmin.class);
streamMetaStore = injector.getInstance(StreamMetaStore.class);
namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
// create namespaces
// This happens when you create a namespace via REST APIs. However, since we do not start AppFabricServer in
// Explore tests, simulating that scenario by explicitly calling DatasetFramework APIs.
createNamespace(NamespaceId.DEFAULT);
createNamespace(NAMESPACE_ID);
createNamespace(OTHER_NAMESPACE_ID);
}
use of org.apache.twill.filesystem.LocationFactory in project cdap by caskdata.
the class StreamUtilsTest method testStreamIdFromLocation.
@Test
public void testStreamIdFromLocation() {
LocationFactory locationFactory = new LocalLocationFactory();
String path = "/cdap/namespaces/default/streams/fooStream";
Location streamBaseLocation = locationFactory.create(path);
StreamId expectedId = NamespaceId.DEFAULT.stream("fooStream");
Assert.assertEquals(expectedId, new StreamId("default", StreamUtils.getStreamNameFromLocation(streamBaseLocation)));
path = "/customLocation/streams/otherstream";
streamBaseLocation = locationFactory.create(path);
expectedId = new StreamId("othernamespace", "otherstream");
Assert.assertEquals(expectedId, new StreamId("othernamespace", StreamUtils.getStreamNameFromLocation(streamBaseLocation)));
}
use of org.apache.twill.filesystem.LocationFactory in project cdap by caskdata.
the class DatasetServiceTestBase method createModuleJar.
protected Location createModuleJar(Class moduleClass, Location... bundleEmbeddedJars) throws IOException {
LocationFactory lf = new LocalLocationFactory(TMP_FOLDER.newFolder());
File[] embeddedJars = new File[bundleEmbeddedJars.length];
for (int i = 0; i < bundleEmbeddedJars.length; i++) {
File file = TMP_FOLDER.newFile();
Files.copy(Locations.newInputSupplier(bundleEmbeddedJars[i]), file);
embeddedJars[i] = file;
}
return AppJarHelper.createDeploymentJar(lf, moduleClass, embeddedJars);
}
use of org.apache.twill.filesystem.LocationFactory in project cdap by caskdata.
the class HBasePayloadTableTestRun method setupBeforeClass.
@BeforeClass
public static void setupBeforeClass() throws Exception {
hConf = HBASE_TEST_BASE.getConfiguration();
hConf.set(HBaseTableUtil.CFG_HBASE_TABLE_COMPRESSION, HBaseTableUtil.CompressionType.NONE.name());
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.set(Constants.CFG_HDFS_NAMESPACE, cConf.get(Constants.CFG_LOCAL_DATA_DIR));
cConf.set(Constants.CFG_HDFS_USER, System.getProperty("user.name"));
tableUtil = new HBaseTableUtilFactory(cConf).get();
ddlExecutor = new HBaseDDLExecutorFactory(cConf, hConf).get();
ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
LocationFactory locationFactory = getInjector().getInstance(LocationFactory.class);
tableFactory = new HBaseTableFactory(cConf, hConf, tableUtil, locationFactory);
new ConfigurationWriter(hConf, cConf).write(ConfigurationReader.Type.DEFAULT, cConf);
}
use of org.apache.twill.filesystem.LocationFactory in project cdap by caskdata.
the class NettyRouterPipelineTest method deploy.
// Deploy word count app n times.
private void deploy(int num) throws Exception {
String path = String.format("http://%s:%d/v1/deploy", HOSTNAME, ROUTER.getServiceMap().get(GATEWAY_NAME));
LocationFactory lf = new LocalLocationFactory(TMP_FOLDER.newFolder());
Location programJar = AppJarHelper.createDeploymentJar(lf, AppWritingtoStream.class);
GATEWAY_SERVER.setExpectedJarBytes(ByteStreams.toByteArray(Locations.newInputSupplier(programJar)));
for (int i = 0; i < num; i++) {
LOG.info("Deploying {}/{}", i, num);
URL url = new URL(path);
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
urlConn.setRequestProperty("X-Archive-Name", "Purchase-1.0.0.jar");
urlConn.setRequestMethod("POST");
urlConn.setDoOutput(true);
urlConn.setDoInput(true);
ByteStreams.copy(Locations.newInputSupplier(programJar), urlConn.getOutputStream());
Assert.assertEquals(200, urlConn.getResponseCode());
urlConn.getInputStream().close();
urlConn.disconnect();
}
}
Aggregations