Package org.apache.accumulo.core.client

Examples of org.apache.accumulo.core.client.AccumuloException


          throw new TableNotFoundException(e);
        case OFFLINE:
          throw new TableOfflineException(instance, null);
        case OTHER:
        default:
          throw new AccumuloException(e.description, e);
      }
    } catch (Exception e) {
      throw new AccumuloException(e.getMessage(), e);
    } finally {
      // always finish table op, even when exception
      if (opid != null)
        try {
          finishTableOperation(opid);
View Full Code Here


  @Deprecated
  public void flush(String tableName) throws AccumuloException, AccumuloSecurityException {
    try {
      flush(tableName, null, null, false);
    } catch (TableNotFoundException e) {
      throw new AccumuloException(e.getMessage(), e);
    }
  }
View Full Code Here

      switch (e.getType()) {
        case NOTFOUND:
          throw new TableNotFoundException(e);
        case OTHER:
        default:
          throw new AccumuloException(e.description, e);
      }
    } catch (Exception e) {
      throw new AccumuloException(e);
    }
  }
View Full Code Here

      switch (e.getType()) {
        case NOTFOUND:
          throw new TableNotFoundException(e);
        case OTHER:
        default:
          throw new AccumuloException(e.description, e);
      }
    } catch (AccumuloException e) {
      throw e;
    } catch (Exception e) {
      throw new AccumuloException(e);
    }
   
  }
View Full Code Here

      throws IOException, AccumuloException, AccumuloSecurityException {
    FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
    Path failPath = new Path(failureDir);
    FileStatus[] listStatus = fs.listStatus(failPath);
    if (fs.exists(failPath) && listStatus != null && listStatus.length != 0)
      throw new AccumuloException("Failure directory exists, and is not empty");
    if (!fs.exists(failPath))
      fs.mkdirs(failPath);
   
    try {
      importDirectory(tableName, dir, failureDir, false);
View Full Code Here

      TableNotFoundException, AccumuloException {
    ArgumentChecker.notNull(tableName, dir, failureDir);
    FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
    Path failPath = fs.makeQualified(new Path(failureDir));
    if (!fs.exists(new Path(dir)))
      throw new AccumuloException("Bulk import directory " + dir + " does not exist!");
    if (!fs.exists(failPath))
      throw new AccumuloException("Bulk import failure directory " + failureDir + " does not exist!");
    FileStatus[] listStatus = fs.listStatus(failPath);
    if (listStatus != null && listStatus.length != 0) {
      if (listStatus.length == 1 && listStatus[0].isDir())
        throw new AccumuloException("Bulk import directory " + failPath + " is a file");
      throw new AccumuloException("Bulk import failure directory " + failPath + " is not empty");
    }
   
    List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(dir.getBytes()), ByteBuffer.wrap(failureDir.getBytes()),
        ByteBuffer.wrap((setTime + "").getBytes()));
    Map<String,String> opts = new HashMap<String,String>();
View Full Code Here

      switch (e.getType()) {
        case EXISTS:
          throw new TableNotFoundException(e);
        case OTHER:
        default:
          throw new AccumuloException(e.getMessage(), e);
      }
    } catch (Exception e) {
      throw new AccumuloException(e.getMessage(), e);
    } finally {
      MasterClient.close(client);
    }
  }
View Full Code Here

     
      try {
        bw = mtbw.getBatchWriter(table);
      } catch (TableNotFoundException e) {
        log.error("Accumulo table " + table + " doesn't exist and cannot be created.", e);
        throw new AccumuloException(e);
      } catch (AccumuloException e) {
        throw e;
      } catch (AccumuloSecurityException e) {
        throw e;
      }
View Full Code Here

      try {
        conn = state.getInstance().getConnector(sourceUser, (SecurityHelper.getTabUserPass(state)));
      } catch (AccumuloSecurityException ae) {
        if (ae.getErrorCode().equals(SecurityErrorCode.BAD_CREDENTIALS)) {
          if (SecurityHelper.getTabUserExists(state))
            throw new AccumuloException("Got a security exception when the user should have existed", ae);
          else
            return;
        }
        throw new AccumuloException("Unexpected exception!", ae);
      }
    }
   
    boolean hasPerm = true;
    if (!source.equals(target))
      hasPerm = SecurityHelper.getSysPerm(state, sourceUser, SystemPermission.ALTER_USER);
   
    boolean targetExists = true;
    boolean targetSystem = true;
    if (target.equals("table")) {
      targetSystem = false;
      if (!SecurityHelper.getTabUserExists(state))
        targetExists = false;
      target = SecurityHelper.getTabUserName(state);
    } else
      target = SecurityHelper.getSysUserName(state);
   
    Random r = new Random();
   
    byte[] newPass = new byte[r.nextInt(50) + 1];
    r.nextBytes(newPass);
    BigInteger bi = new BigInteger(newPass);
    newPass = bi.toString(36).getBytes();
   
    try {
      conn.securityOperations().changeUserPassword(target, newPass);
    } catch (AccumuloSecurityException ae) {
      switch (ae.getErrorCode()) {
        case PERMISSION_DENIED:
          if (hasPerm)
            throw new AccumuloException("Change failed when it should have succeeded to change " + target + "'s password", ae);
          return;
        case USER_DOESNT_EXIST:
          if (targetExists)
            throw new AccumuloException("User " + target + " doesn't exist and they SHOULD.", ae);
          return;
        default:
          throw new AccumuloException("Got unexpected exception", ae);
      }
    }
    if (targetSystem) {
      SecurityHelper.setSysUserPass(state, newPass);
    } else
      SecurityHelper.setTabUserPass(state, newPass);
    // Waiting 1 second for password to propogate through Zk
    Thread.sleep(1000);
    if (!hasPerm)
      throw new AccumuloException("Password change succeeded when it should have failed.");
  }
View Full Code Here

      }
    } else {
      try {
        scanner = new IsolatedScanner(instance.getConnector(credentials).createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS));
      } catch (AccumuloSecurityException ex) {
        throw new AccumuloException(ex);
      } catch (TableNotFoundException ex) {
        throw new AccumuloException(ex);
      }
    }
   
    // skip candidates that are in a bulk processing folder
    if (checkForBulkProcessingFiles) {
     
      log.debug("Checking for bulk processing flags");
     
      scanner.setRange(Constants.METADATA_BLIP_KEYSPACE);
     
      // WARNING: This block is IMPORTANT
      // You MUST REMOVE candidates that are in the same folder as a bulk
      // processing flag!
     
      for (Entry<Key,Value> entry : scanner) {
        String blipPath = entry.getKey().getRow().toString().substring(Constants.METADATA_BLIP_FLAG_PREFIX.length());
        validateDir(blipPath);
        Iterator<String> tailIter = candidates.tailSet(blipPath).iterator();
        int count = 0;
        while (tailIter.hasNext()) {
          if (tailIter.next().startsWith(blipPath)) {
            count++;
            tailIter.remove();
          } else {
            break;
          }
        }
       
        if (count > 0)
          log.debug("Folder has bulk processing flag: " + blipPath);
       
      }
    }
   
    // skip candidates that are still in use in the file column family in
    // the metadata table
    scanner.clearColumns();
    scanner.fetchColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY);
    scanner.fetchColumnFamily(Constants.METADATA_SCANFILE_COLUMN_FAMILY);
    ColumnFQ.fetch(scanner, Constants.METADATA_DIRECTORY_COLUMN);
   
    TabletIterator tabletIterator = new TabletIterator(scanner, Constants.METADATA_KEYSPACE, false, true);
   
    while (tabletIterator.hasNext()) {
      Map<Key,Value> tabletKeyValues = tabletIterator.next();
     
      for (Entry<Key,Value> entry : tabletKeyValues.entrySet()) {
        if (entry.getKey().getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)
            || entry.getKey().getColumnFamily().equals(Constants.METADATA_SCANFILE_COLUMN_FAMILY)) {
         
          String cf = entry.getKey().getColumnQualifier().toString();
          String delete;
          if (cf.startsWith("../")) {
            delete = cf.substring(2);
          } else {
            String table = new String(KeyExtent.tableOfMetadataRow(entry.getKey().getRow()));
            delete = "/" + table + cf;
          }
          // WARNING: This line is EXTREMELY IMPORTANT.
          // You MUST REMOVE candidates that are still in use
          validateFile(delete);
          if (candidates.remove(delete))
            log.debug("Candidate was still in use in the METADATA table: " + delete);
         
          String path = delete.substring(0, delete.lastIndexOf('/'));
          validateDir(path);
          if (candidates.remove(path))
            log.debug("Candidate was still in use in the METADATA table: " + path);
        } else if (Constants.METADATA_DIRECTORY_COLUMN.hasColumns(entry.getKey())) {
          String table = new String(KeyExtent.tableOfMetadataRow(entry.getKey().getRow()));
          String delete = "/" + table + entry.getValue().toString();
          validateDir(delete);
          if (candidates.remove(delete))
            log.debug("Candidate was still in use in the METADATA table: " + delete);
        } else
          throw new AccumuloException("Scanner over metadata table returned unexpected column : " + entry.getKey());
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.AccumuloException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.