private void decodeRows(TreeMap<Key,Value> encodedResults, TreeMap<Key,Value> results) throws AccumuloException { for (Entry<Key,Value> entry : encodedResults.entrySet()) { try { results.putAll(WholeRowIterator.decodeRow(entry.getKey(), entry.getValue())); } catch (IOException e) { throw new AccumuloException(e); } } }
@Override public String next() { String tserver = iter.next(); try { instanceOps.ping(tserver); } catch (AccumuloException e) { return tserver + " ERROR " + e.getMessage(); } return tserver + " OK"; }
while (results == null && !scanState.finished) { if (Thread.currentThread().isInterrupted()) { throw new AccumuloException("Thread interrupted"); throw e; } catch (AccumuloException e) { error = "exception from tablet loc " + e.getMessage(); if (!error.equals(lastError)) log.debug("{}", error); throw new AccumuloException(ex); } finally { span.stop();
private void handleAccumuloException(AccumuloException e) throws org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException { if (e.getCause() instanceof ThriftTableOperationException) { ThriftTableOperationException ttoe = (ThriftTableOperationException) e.getCause(); if (ttoe.type == TableOperationExceptionType.NOTFOUND) { throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString()); } } throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString()); }
public void setLocalityGroups() { HashMap<String, Set<Text>> localityGroups = new HashMap<String, Set<Text>>(); Iterator<String> groups = getPredicates(); int i = 1; while(groups.hasNext()) { HashSet<Text> tempColumn = new HashSet<Text>(); String temp = groups.next(); tempColumn.add(new Text(temp)); String groupName = "predicate" + i; localityGroups.put(groupName, tempColumn); i++; } try { conn.tableOperations().setLocalityGroups(tablePrefix + "doc_partitioned_index", localityGroups); //conn.tableOperations().compact(tablePrefix + "doc_partitioned_index", null, null, true, true); } catch (AccumuloException e) { e.printStackTrace(); } catch (AccumuloSecurityException e) { e.printStackTrace(); } catch (TableNotFoundException e) { e.printStackTrace(); } }
public void setLocalityGroups() { HashMap<String, Set<Text>> localityGroups = new HashMap<String, Set<Text>>(); Iterator<String> groups = getPredicates(); int i = 1; while(groups.hasNext()) { HashSet<Text> tempColumn = new HashSet<Text>(); String temp = groups.next(); tempColumn.add(new Text(temp)); String groupName = "predicate" + i; localityGroups.put(groupName, tempColumn); i++; } try { conn.tableOperations().setLocalityGroups(tablePrefix + "doc_partitioned_index", localityGroups); //conn.tableOperations().compact(tablePrefix + "doc_partitioned_index", null, null, true, true); } catch (AccumuloException e) { e.printStackTrace(); } catch (AccumuloSecurityException e) { e.printStackTrace(); } catch (TableNotFoundException e) { e.printStackTrace(); } }
/** * Check path of bulk directory and permissions */ private Path checkPath(FileSystem fs, String dir) throws IOException, AccumuloException { Path ret; if (dir.contains(":")) { ret = new Path(dir); } else { ret = fs.makeQualified(new Path(dir)); } try { if (!fs.getFileStatus(ret).isDirectory()) { throw new AccumuloException("Bulk import directory " + dir + " is not a directory!"); } Path tmpFile = new Path(ret, "isWritable"); if (fs.createNewFile(tmpFile)) fs.delete(tmpFile, true); else throw new AccumuloException("Bulk import directory " + dir + " is not writable."); } catch (FileNotFoundException fnf) { throw new AccumuloException( "Bulk import directory " + dir + " does not exist or has bad permissions", fnf); } // TODO ensure dir does not contain bulk load mapping return ret; }
private static int ping(ClientContext context, List<String> args) { InstanceOperations io = context.instanceOperations(); if (args.size() == 0) { args = io.getTabletServers(); } int unreachable = 0; for (String tserver : args) { try { io.ping(tserver); System.out.println(tserver + " OK"); } catch (AccumuloException ae) { System.out.println(tserver + " FAILED (" + ae.getMessage() + ")"); unreachable++; } } System.out.printf("\n%d of %d tablet servers unreachable\n\n", unreachable, args.size()); return unreachable; }
@Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); try { conn.tableOperations().create(tableName); log.debug("Created table " + tableName); } catch (TableExistsException e) { log.debug("Create " + tableName + " failed, it exists"); } catch (AccumuloException e) { if (e.getCause() != null && e.getCause() instanceof NamespaceNotFoundException) log.debug("Create " + tableName + " failed, the namespace does not exist"); else throw e; } catch (IllegalArgumentException e) { log.debug("Create: " + e.toString()); } catch (AccumuloSecurityException e) { log.debug("Could not create table: " + e); } } }
public AccumuloSelectivityEvalDAO(RdfCloudTripleStoreConfiguration conf) { this.conf = conf; Instance inst = new ZooKeeperInstance(conf.get("sc.cloudbase.instancename"), conf.get("sc.cloudbase.zookeepers")); try { this.connector = inst.getConnector(conf.get("sc.cloudbase.username"), conf.get("sc.cloudbase.password")); } catch (AccumuloException e) { e.printStackTrace(); } catch (AccumuloSecurityException e) { e.printStackTrace(); } }
@Override public void setProperty(final String tableName, final String property, final String value) throws AccumuloException, AccumuloSecurityException { checkArgument(tableName != null, "tableName is null"); checkArgument(property != null, "property is null"); checkArgument(value != null, "value is null"); try { setPropertyNoChecks(tableName, property, value); checkLocalityGroups(tableName, property); } catch (TableNotFoundException e) { throw new AccumuloException(e); } }
@Override public void createUser(String principal, AuthenticationToken token) throws AccumuloSecurityException { try { if (!(token instanceof PasswordToken)) throw new AccumuloSecurityException(principal, SecurityErrorCode.INVALID_TOKEN); PasswordToken pt = (PasswordToken) token; constructUser(principal, ZKSecurityTool.createPass(pt.getPassword())); } catch (KeeperException e) { if (e.code().equals(KeeperException.Code.NODEEXISTS)) throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_EXISTS, e); throw new AccumuloSecurityException(principal, SecurityErrorCode.CONNECTION_ERROR, e); } catch (InterruptedException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); throw new AccumuloSecurityException(principal, SecurityErrorCode.DEFAULT_SECURITY_ERROR, e); } }
log.debug("Clone: " + e.toString()); } catch (AccumuloException e) { Throwable cause = e.getCause(); if (cause != null && cause instanceof NamespaceNotFoundException) log.debug(
private void init() { try { accCon = ConfigUtils.getConnector(conf); } catch (AccumuloException e) { e.printStackTrace(); } catch (AccumuloSecurityException e) { e.printStackTrace(); } try { if (conf.isUseStats() && conf.isUseSelectivity()) { ProspectorServiceEvalStatsDAO evalDao = new ProspectorServiceEvalStatsDAO(accCon, conf); evalDao.init(); AccumuloSelectivityEvalDAO ase = new AccumuloSelectivityEvalDAO(conf, accCon); ase.setRdfEvalDAO(evalDao); ase.init(); cardinality = starQuery.getCardinality(ase); CardinalityStatementPattern csp = starQuery.getMinCardSp(ase); minCard = csp.getCardinality(); minSp = csp.getSp(); } else { // TODO come up with a better default if cardinality is not // initialized cardinality = minCard = 1; minSp = starQuery.getNodes().get(0); } } catch(final Exception e) { LOG.warn("A problem was encountered while initializing the EntityTupleSet.", e); } }
@Override public void removeProperty(final String tableName, final String property) throws AccumuloException, AccumuloSecurityException { checkArgument(tableName != null, "tableName is null"); checkArgument(property != null, "property is null"); try { removePropertyNoChecks(tableName, property); checkLocalityGroups(tableName, property); } catch (TableNotFoundException e) { throw new AccumuloException(e); } }
@Override public void changePassword(String principal, AuthenticationToken token) throws AccumuloSecurityException { if (!(token instanceof PasswordToken)) throw new AccumuloSecurityException(principal, SecurityErrorCode.INVALID_TOKEN); PasswordToken pt = (PasswordToken) token; if (userExists(principal)) { try { synchronized (zooCache) { zooCache.clear(ZKUserPath + "/" + principal); context.getZooReaderWriter().putPrivatePersistentData(ZKUserPath + "/" + principal, ZKSecurityTool.createPass(pt.getPassword()), NodeExistsPolicy.OVERWRITE); } } catch (KeeperException e) { log.error("{}", e.getMessage(), e); throw new AccumuloSecurityException(principal, SecurityErrorCode.CONNECTION_ERROR, e); } catch (InterruptedException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); throw new AccumuloSecurityException(principal, SecurityErrorCode.DEFAULT_SECURITY_ERROR, e); } } else // user doesn't exist throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST); }
private void init() { try { accCon = ConfigUtils.getConnector(conf); } catch (AccumuloException e) { e.printStackTrace(); } catch (AccumuloSecurityException e) { e.printStackTrace(); } try { if (conf.isUseStats() && conf.isUseSelectivity()) { ProspectorServiceEvalStatsDAO evalDao = new ProspectorServiceEvalStatsDAO(accCon, conf); evalDao.init(); AccumuloSelectivityEvalDAO ase = new AccumuloSelectivityEvalDAO(conf, accCon); ase.setRdfEvalDAO(evalDao); ase.init(); cardinality = starQuery.getCardinality(ase); CardinalityStatementPattern csp = starQuery.getMinCardSp(ase); minCard = csp.getCardinality(); minSp = csp.getSp(); } else { // TODO come up with a better default if cardinality is not // initialized cardinality = minCard = 1; minSp = starQuery.getNodes().get(0); } } catch(final Exception e) { LOG.warn("A problem was encountered while initializing the EntityTupleSet.", e); } }
@Override public Map<String,Integer> listConstraints(String namespace) throws AccumuloException, NamespaceNotFoundException, AccumuloSecurityException { Map<String,Integer> constraints = new TreeMap<>(); for (Entry<String,String> property : this.getProperties(namespace)) { if (property.getKey().startsWith(Property.TABLE_CONSTRAINT_PREFIX.toString())) { if (constraints.containsKey(property.getValue())) throw new AccumuloException("Same constraint configured twice: " + property.getKey() + "=" + Property.TABLE_CONSTRAINT_PREFIX + constraints.get(property.getValue()) + "=" + property.getKey()); try { constraints.put(property.getValue(), Integer.parseInt( property.getKey().substring(Property.TABLE_CONSTRAINT_PREFIX.toString().length()))); } catch (NumberFormatException e) { throw new AccumuloException("Bad key for existing constraint: " + property); } } } return constraints; } }