Refine search
private void printTableConfiguration(Connector connector, String tableName, File outputDirectory) throws AccumuloException, TableNotFoundException, IOException, AccumuloSecurityException { File tableBackup = new File(outputDirectory, tableName + ".cfg"); FileWriter writer = new FileWriter(tableBackup); writer.write(createTableFormat.format(new String[] {tableName})); TreeMap<String,String> props = new TreeMap<>(); for (Entry<String,String> p : connector.tableOperations().getProperties(tableName)) { props.put(p.getKey(), p.getValue()); } for (Entry<String,String> prop : props.entrySet()) { if (prop.getKey().startsWith(Property.TABLE_PREFIX.getKey())) { String defaultValue = getDefaultConfigValue(prop.getKey()); if (defaultValue == null || !defaultValue.equals(prop.getValue())) { if (!prop.getValue().equals(siteConfig.get(prop.getKey())) && !prop.getValue().equals(systemConfig.get(prop.getKey()))) { writer.write(configFormat .format(new String[] {tableName, prop.getKey() + "=" + prop.getValue()})); } } } } writer.close(); } }
@Test public void test() throws Exception { final Connector c = getConnector(); final String tableName = getUniqueNames(1)[0]; c.tableOperations().create(tableName); c.tableOperations().setProperty(tableName, Property.TABLE_COMPACTION_STRATEGY.getKey(), SimpleCompactionStrategy.class.getName()); runTest(c, tableName, 3); c.tableOperations().setProperty(tableName, Property.TABLE_COMPACTION_STRATEGY_PREFIX.getKey() + "count", "" + 5); runTest(c, tableName, 5); }
static void createIndexTable(Logger log, State state, Environment env, String suffix, Random rand) throws Exception { Connector conn = env.getConnector(); String name = (String) state.get("indexTableName") + suffix; int numPartitions = (Integer) state.get("numPartitions"); boolean enableCache = (Boolean) state.get("cacheIndex"); conn.tableOperations().create(name); String tableId = conn.tableOperations().tableIdMap().get(name); log.info("Created index table " + name + "(id:" + tableId + ")"); SortedSet<Text> splits = genSplits(numPartitions, rand.nextInt(numPartitions) + 1, "%06x"); conn.tableOperations().addSplits(name, splits); log.info("Added " + splits.size() + " splits to " + name); if (enableCache) { conn.tableOperations().setProperty(name, Property.TABLE_INDEXCACHE_ENABLED.getKey(), "true"); conn.tableOperations().setProperty(name, Property.TABLE_BLOCKCACHE_ENABLED.getKey(), "true"); log.info("Enabled caching for table " + name); } }
@Test public void verifySystemPropertyInheritance() throws Exception { String t1 = "1"; String t2 = namespace + "." + t1; c.tableOperations().create(t1); c.namespaceOperations().create(namespace); c.tableOperations().create(t2); // verify iterator inheritance _verifySystemPropertyInheritance(t1, t2, Property.TABLE_ITERATOR_PREFIX.getKey() + "scan.sum", "20," + SimpleFilter.class.getName(), false); // verify constraint inheritance _verifySystemPropertyInheritance(t1, t2, Property.TABLE_CONSTRAINT_PREFIX.getKey() + "42", NumericValueConstraint.class.getName(), false); // verify other inheritance _verifySystemPropertyInheritance(t1, t2, Property.TABLE_LOCALITY_GROUP_PREFIX.getKey() + "dummy", "dummy", true); }
protected String getPeerType(String peerName) { // Find the configured replication peer so we know how to replicate to it Map<String,String> configuredPeers = conf .getAllPropertiesWithPrefix(Property.REPLICATION_PEERS); String peerType = configuredPeers.get(Property.REPLICATION_PEERS.getKey() + peerName); if (peerType == null) { String msg = "Cannot process replication for unknown peer: " + peerName; log.warn(msg); throw new IllegalArgumentException(msg); } return peerType; }
@Before public void offlineTraceTable() throws Exception { Connector conn = getConnector(); String traceTable = conn.instanceOperations().getSystemConfiguration() .get(Property.TRACE_TABLE.getKey()); if (conn.tableOperations().exists(traceTable)) { conn.tableOperations().offline(traceTable, true); } }
private void test1(Connector c) throws Exception { basicTest(c, REG_TABLE_NAME, 0); c.tableOperations().setProperty(REG_TABLE_NAME, Property.TABLE_SPLIT_THRESHOLD.getKey(), "" + SPLIT_THRESH); sleepUninterruptibly(timeoutFactor * 12, TimeUnit.SECONDS); log.info("checking splits"); FunctionalTestUtils.checkSplits(c, REG_TABLE_NAME, NUM_PRE_SPLITS / 2, NUM_PRE_SPLITS * 4); verify(c, REG_TABLE_NAME); }
protected String getPassword(AccumuloConfiguration localConf, ReplicationTarget target) { requireNonNull(localConf); requireNonNull(target); Map<String,String> peerPasswords = localConf .getAllPropertiesWithPrefix(Property.REPLICATION_PEER_PASSWORD); String password = peerPasswords .get(Property.REPLICATION_PEER_PASSWORD.getKey() + target.getPeerName()); if (password == null) { throw new IllegalArgumentException("Cannot get password for " + target.getPeerName()); } return password; }
@After public void onlineTraceTable() throws Exception { if (null != cluster) { Connector conn = getConnector(); String traceTable = conn.instanceOperations().getSystemConfiguration() .get(Property.TRACE_TABLE.getKey()); if (conn.tableOperations().exists(traceTable)) { conn.tableOperations().online(traceTable, true); } } }
private String[] init() throws Exception { String[] tableNames = getUniqueNames(4); Connector c = getConnector(); TableOperations tableOps = c.tableOperations(); createTable(tableNames[0]); createTable(tableNames[1]); createTable(tableNames[2]); createTable(tableNames[3]); // default is sync tableOps.setProperty(tableNames[1], Property.TABLE_DURABILITY.getKey(), "flush"); tableOps.setProperty(tableNames[2], Property.TABLE_DURABILITY.getKey(), "log"); tableOps.setProperty(tableNames[3], Property.TABLE_DURABILITY.getKey(), "none"); return tableNames; }
protected String getKeytab(AccumuloConfiguration localConf, ReplicationTarget target) { requireNonNull(localConf); requireNonNull(target); Map<String,String> peerKeytabs = localConf .getAllPropertiesWithPrefix(Property.REPLICATION_PEER_KEYTAB); String keytab = peerKeytabs .get(Property.REPLICATION_PEER_KEYTAB.getKey() + target.getPeerName()); if (keytab == null) { throw new IllegalArgumentException("Cannot get keytab for " + target.getPeerName()); } return keytab; }
@Test(timeout = 4 * 60 * 1000) public void testMetaDurability() throws Exception { Connector c = getConnector(); String tableName = getUniqueNames(1)[0]; c.instanceOperations().setProperty(Property.TABLE_DURABILITY.getKey(), "none"); Map<String,String> props = map(c.tableOperations().getProperties(MetadataTable.NAME)); assertEquals("sync", props.get(Property.TABLE_DURABILITY.getKey())); c.tableOperations().create(tableName); props = map(c.tableOperations().getProperties(tableName)); assertEquals("none", props.get(Property.TABLE_DURABILITY.getKey())); restartTServer(); assertTrue(c.tableOperations().exists(tableName)); }
@Test public void createTableWithProperties() throws Exception { final String table = name.getMethodName(); // create table with initial properties String testProp = "table.custom.description=description,table.custom.testProp=testProp," + Property.TABLE_SPLIT_THRESHOLD.getKey() + "=10K"; ts.exec("createtable " + table + " -prop " + testProp, true); ts.exec("insert a b c value", true); ts.exec("scan", true, "value", true); Connector connector = getConnector(); for (Entry<String,String> entry : connector.tableOperations().getProperties(table)) { if (entry.getKey().equals("table.custom.description")) Assert.assertTrue("Initial property was not set correctly", entry.getValue().equals("description")); if (entry.getKey().equals("table.custom.testProp")) Assert.assertTrue("Initial property was not set correctly", entry.getValue().equals("testProp")); if (entry.getKey().equals(Property.TABLE_SPLIT_THRESHOLD.getKey())) Assert.assertTrue("Initial property was not set correctly", entry.getValue().equals("10K")); } ts.exec("deletetable -f " + table); }
@Override public String get(Property property) { if (Property.isFixedZooPropertyKey(property)) { String val = fixedProps.get(property.getKey()); if (val != null) { return val; } else { synchronized (fixedProps) { val = _get(property); fixedProps.put(property.getKey(), val); return val; } } } else { return _get(property); } }
@Test public void testCombinerSetOnMetadata() throws Exception { TableOperations tops = getConnector().tableOperations(); Map<String,EnumSet<IteratorScope>> iterators = tops.listIterators(MetadataTable.NAME); Assert.assertTrue(iterators.containsKey(ReplicationTableUtil.COMBINER_NAME)); EnumSet<IteratorScope> scopes = iterators.get(ReplicationTableUtil.COMBINER_NAME); Assert.assertEquals(3, scopes.size()); Assert.assertTrue(scopes.contains(IteratorScope.scan)); Assert.assertTrue(scopes.contains(IteratorScope.minc)); Assert.assertTrue(scopes.contains(IteratorScope.majc)); Iterable<Entry<String,String>> propIter = tops.getProperties(MetadataTable.NAME); HashMap<String,String> properties = new HashMap<>(); for (Entry<String,String> entry : propIter) { properties.put(entry.getKey(), entry.getValue()); } for (IteratorScope scope : scopes) { String key = Property.TABLE_ITERATOR_PREFIX.getKey() + scope.name() + "." + ReplicationTableUtil.COMBINER_NAME + ".opt.columns"; Assert.assertTrue("Properties did not contain key : " + key, properties.containsKey(key)); Assert.assertEquals(MetadataSchema.ReplicationSection.COLF.toString(), properties.get(key)); } }
@Test public void run() throws Exception { Random r = new Random(); byte rowData[] = new byte[ROW_SIZE]; r.setSeed(SEED + 1); TreeSet<Text> splitPoints = new TreeSet<>(); for (int i = 0; i < NUM_PRE_SPLITS; i++) { r.nextBytes(rowData); TestIngest.toPrintableChars(rowData); splitPoints.add(new Text(rowData)); } Connector c = getConnector(); c.tableOperations().create(REG_TABLE_NAME); c.tableOperations().create(PRE_SPLIT_TABLE_NAME); c.tableOperations().setProperty(PRE_SPLIT_TABLE_NAME, Property.TABLE_MAX_END_ROW_SIZE.getKey(), "256K"); sleepUninterruptibly(3, TimeUnit.SECONDS); c.tableOperations().addSplits(PRE_SPLIT_TABLE_NAME, splitPoints); test1(c); test2(c); }
/** * Re-reads the max threads from the configuration that created this class */ public int getCurrentMaxThreads() { Integer depThreads = getDeprecatedScanThreads(name); if (depThreads != null) { return depThreads; } String prop = Property.TSERV_SCAN_EXECUTORS_PREFIX.getKey() + name + "." + SCAN_EXEC_THREADS; String val = getAllPropertiesWithPrefix(Property.TSERV_SCAN_EXECUTORS_PREFIX).get(prop); return Integer.parseInt(val); } }
@Test public void binaryStressTest() throws Exception { Connector c = getConnector(); String tableName = getUniqueNames(1)[0]; c.tableOperations().create(tableName); c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K"); BinaryIT.runTest(c, tableName); String id = c.tableOperations().tableIdMap().get(tableName); Set<Text> tablets = new HashSet<>(); Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.setRange(Range.prefix(id)); for (Entry<Key,Value> entry : s) { tablets.add(entry.getKey().getRow()); } assertTrue("Expected at least 8 tablets, saw " + tablets.size(), tablets.size() > 7); }