/** * @since 1.6.0 */ public MiniAccumuloConfig getConfig() { return new MiniAccumuloConfig(impl.getConfig()); }
private void setCoreSite(MiniAccumuloClusterImpl cluster) throws Exception { File csFile = new File(cluster.getConfig().getConfDir(), "core-site.xml"); if (csFile.exists()) throw new RuntimeException(csFile + " already exist"); Configuration coreSite = new Configuration(false); coreSite.set("fs.file.impl", RawLocalFileSystem.class.getName()); OutputStream out = new BufferedOutputStream( new FileOutputStream(new File(cluster.getConfig().getConfDir(), "core-site.xml"))); coreSite.writeXml(out); out.close(); }
public static File getMiniClusterDir() { return cluster.getConfig().getDir(); }
private int countFiles() throws Exception { Path path = new Path(cluster.getConfig().getDir() + "/accumulo/tables/1/*/*.rf"); return Iterators.size(Arrays.asList(cluster.getFileSystem().globStatus(path)).iterator()); }
@Override public Entry<Integer,String> execWithStdout(Class<?> clz, String[] args) throws IOException { Process p = cluster.exec(clz, args); int exitCode; try { exitCode = p.waitFor(); } catch (InterruptedException e) { log.warn("Interrupted waiting for process to exit", e); Thread.currentThread().interrupt(); throw new IOException(e); } for (LogWriter writer : cluster.getLogWriters()) { writer.flush(); } return Maps.immutableEntry(exitCode, readAll(new FileInputStream(cluster.getConfig().getLogDir() + "/" + clz.getSimpleName() + "_" + p.hashCode() + ".out"))); }
public static String readAll(MiniAccumuloClusterImpl c, Class<?> klass, Process p) throws Exception { for (LogWriter writer : c.getLogWriters()) writer.flush(); return readAll(new FileInputStream( c.getConfig().getLogDir() + "/" + klass.getSimpleName() + "_" + p.hashCode() + ".out")); }
@Test public void testSiteConfiguration() throws Exception { // get something we know is in the site config MiniAccumuloClusterImpl cluster = SharedMiniClusterBase.getCluster(); Map<String,String> cfg = client.getSiteConfiguration(creds); assertTrue(cfg.get("instance.dfs.dir") .startsWith(cluster.getConfig().getAccumuloDir().getAbsolutePath())); }
@Before public void checkCluster() { Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI)); MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster(); rootPath = mac.getConfig().getDir().getAbsolutePath(); }
protected ClientConfiguration getClientConfig() throws Exception { return ClientConfiguration.fromFile(getCluster().getConfig().getClientConfFile()); }
@Test public void bulk() throws Exception { BulkIT.runTest(getConnector(), cluster.getFileSystem(), new Path(getCluster().getConfig().getDir().getAbsolutePath(), "tmp"), "root", getUniqueNames(1)[0], this.getClass().getName(), testName.getMethodName()); }
private void createMiniAccumulo() throws Exception { // createTestDir will give us a empty directory, we don't need to clean it up ourselves File baseDir = createTestDir(this.getClass().getName() + "_" + this.testName.getMethodName()); MiniAccumuloConfigImpl cfg = new MiniAccumuloConfigImpl(baseDir, ROOT_PASSWORD); String nativePathInDevTree = NativeMapIT.nativeMapLocation().getAbsolutePath(); String nativePathInMapReduce = new File(System.getProperty("user.dir")).toString(); cfg.setNativeLibPaths(nativePathInDevTree, nativePathInMapReduce); cfg.setProperty(Property.GC_FILE_ARCHIVE, Boolean.TRUE.toString()); Configuration coreSite = new Configuration(false); configure(cfg, coreSite); cfg.setProperty(Property.TSERV_NATIVEMAP_ENABLED, Boolean.TRUE.toString()); configureForEnvironment(cfg, getClass(), getSslDir(baseDir)); cluster = new MiniAccumuloClusterImpl(cfg); if (coreSite.size() > 0) { File csFile = new File(cluster.getConfig().getConfDir(), "core-site.xml"); if (csFile.exists()) { coreSite.addResource(new Path(csFile.getAbsolutePath())); } File tmp = new File(csFile.getAbsolutePath() + ".tmp"); OutputStream out = new BufferedOutputStream(new FileOutputStream(tmp)); coreSite.writeXml(out); out.close(); assertTrue(tmp.renameTo(csFile)); } beforeClusterStart(cfg); }
new Path(cluster.getConfig().getConfDir().toURI().toString(), "accumulo-site.xml")); v1.toString() + "," + v2.toString() + "," + v3.toString()); BufferedOutputStream fos = new BufferedOutputStream( new FileOutputStream(new File(cluster.getConfig().getConfDir(), "accumulo-site.xml"))); conf.writeXml(fos); fos.close();
@Test public void gcLotsOfCandidatesIT() throws Exception { killMacGc(); log.info("Filling metadata table with bogus delete flags"); Connector c = getConnector(); addEntries(c, new BatchWriterOpts()); cluster.getConfig().setDefaultMemory(10, MemoryUnit.MEGABYTE); Process gc = cluster.exec(SimpleGarbageCollector.class); sleepUninterruptibly(20, TimeUnit.SECONDS); String output = ""; while (!output.contains("delete candidates has exceeded")) { byte buffer[] = new byte[10 * 1024]; try { int n = gc.getInputStream().read(buffer); output = new String(buffer, 0, n, UTF_8); } catch (IOException ex) { break; } } gc.destroy(); assertTrue(output.contains("delete candidates has exceeded")); }
private int countWALsInFS(MiniAccumuloClusterImpl cluster) throws Exception { FileSystem fs = cluster.getFileSystem(); RemoteIterator<LocatedFileStatus> iterator = fs .listFiles(new Path(cluster.getConfig().getAccumuloDir() + "/wal"), true); int result = 0; while (iterator.hasNext()) { LocatedFileStatus next = iterator.next(); if (!next.isDirectory()) { result++; } } return result; } }
@Before public void startMac() throws Exception { MiniClusterHarness harness = new MiniClusterHarness(); mac = harness.create(this, new PasswordToken("unused"), kdc, new MiniClusterConfigurationCallback() { @Override public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration coreSite) { Map<String,String> site = cfg.getSiteConfig(); site.put(Property.INSTANCE_ZK_TIMEOUT.getKey(), "15s"); cfg.setSiteConfig(site); } }); mac.getConfig().setNumTservers(1); mac.start(); // Enabled kerberos auth Configuration conf = new Configuration(false); conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "kerberos"); UserGroupInformation.setConfiguration(conf); }
@Before public void startMac() throws Exception { MiniClusterHarness harness = new MiniClusterHarness(); mac = harness.create(this, new PasswordToken("unused"), kdc, new MiniClusterConfigurationCallback() { @Override public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration coreSite) { Map<String,String> site = cfg.getSiteConfig(); site.put(Property.INSTANCE_ZK_TIMEOUT.getKey(), "15s"); // Reduce the period just to make sure we trigger renewal fast site.put(Property.GENERAL_KERBEROS_RENEWAL_PERIOD.getKey(), "5s"); cfg.setSiteConfig(site); } }); mac.getConfig().setNumTservers(1); mac.start(); // Enabled kerberos auth Configuration conf = new Configuration(false); conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "kerberos"); UserGroupInformation.setConfiguration(conf); }
@Test public void testPerTableClasspath() throws Exception { final Connector c = getConnector(); final String tableName = getUniqueNames(1)[0]; File destFile = installJar(getCluster().getConfig().getAccumuloDir(), "/TestCompactionStrat.jar"); c.tableOperations().create(tableName); c.instanceOperations().setProperty( Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + "context1", destFile.toString()); c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "10"); c.tableOperations().setProperty(tableName, Property.TABLE_CLASSPATH.getKey(), "context1"); // EfgCompactionStrat will only compact a tablet w/ end row of 'efg'. No other tablets are // compacted. c.tableOperations().setProperty(tableName, Property.TABLE_COMPACTION_STRATEGY.getKey(), "org.apache.accumulo.test.EfgCompactionStrat"); c.tableOperations().addSplits(tableName, new TreeSet<>(Arrays.asList(new Text("efg")))); for (char ch = 'a'; ch < 'l'; ch++) writeFlush(c, tableName, ch + ""); while (countFiles(c, tableName) != 7) { UtilWaitThread.sleep(200); } }