Package org.apache.accumulo.core.client.impl.thrift

Examples of org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException


 
  private void checkNotMetadataTable(String tableName, TableOperation operation) throws ThriftTableOperationException {
    if (tableName.compareTo(Constants.METADATA_TABLE_NAME) == 0) {
      String why = "Table names cannot be == " + Constants.METADATA_TABLE_NAME;
      log.warn(why);
      throw new ThriftTableOperationException(null, tableName, operation, TableOperationExceptionType.OTHER, why);
    }
  }
View Full Code Here


 
  private void checkTableName(String tableName, TableOperation operation) throws ThriftTableOperationException {
    if (!tableName.matches(Constants.VALID_TABLE_NAME_REGEX)) {
      String why = "Table names must only contain word characters (letters, digits, and underscores): " + tableName;
      log.warn(why);
      throw new ThriftTableOperationException(null, tableName, operation, TableOperationExceptionType.OTHER, why);
    }
  }
View Full Code Here

 
  private void verify(AuthInfo credentials, String tableId, TableOperation op, boolean match) throws ThriftSecurityException, ThriftTableOperationException {
    if (!match) {
      Tables.clearCache(instance);
      if (!Tables.exists(instance, tableId))
        throw new ThriftTableOperationException(tableId, null, op, TableOperationExceptionType.NOTFOUND, null);
      else
        throw new AccumuloSecurityException(credentials.user, SecurityErrorCode.PERMISSION_DENIED).asThriftException();
    }
  }
View Full Code Here

  }
 
  public void mustBeOnline(final String tableId) throws ThriftTableOperationException {
    Tables.clearCache(instance);
    if (!Tables.getTableState(instance, tableId).equals(TableState.ONLINE))
      throw new ThriftTableOperationException(tableId, null, TableOperation.MERGE, TableOperationExceptionType.OFFLINE, "table is not online");
  }
View Full Code Here

    Path writable = new Path(this.errorDir, ".iswritable");
    if (!fs.createNewFile(writable)) {
      // Maybe this is a re-try... clear the flag and try again
      fs.delete(writable, false);
      if (!fs.createNewFile(writable))
        throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY,
            "Unable to write to " + this.errorDir);
    }
    fs.delete(writable, false);
   
    final Set<String> filesToLoad = Collections.synchronizedSet(new HashSet<String>());
View Full Code Here

      reserve1 = reserve2 = Utils.reserveHdfsDirectory(sourceDir, tid);
      if (reserve1 == 0)
        reserve2 = Utils.reserveHdfsDirectory(errorDir, tid);
      return reserve2;
    } else {
      throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.OFFLINE, null);
    }
  }
View Full Code Here

        ServerConfiguration.getSiteConfiguration()));
    ;
    Path errorPath = new Path(errorDir);
    FileStatus errorStatus = fs.getFileStatus(errorPath);
    if (errorStatus == null)
      throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir
          + " does not exist");
    if (!errorStatus.isDir())
      throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir
          + " is not a directory");
    if (fs.listStatus(errorPath).length != 0)
      throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir
          + " is not empty");
   
    ZooArbitrator.start(Constants.BULK_ARBITRATOR_TYPE, tid);
   
    // move the files into the directory
    try {
      String bulkDir = prepareBulkImport(fs, sourceDir, tableId);
      log.debug(" tid " + tid + " bulkDir " + bulkDir);
      return new LoadFiles(tableId, sourceDir, bulkDir, errorDir, setTime);
    } catch (IOException ex) {
      log.error("error preparing the bulk import directory", ex);
      throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_INPUT_DIRECTORY, sourceDir + ": "
          + ex);
    }
  }
View Full Code Here

          nextId = nextId.add(BigInteger.ONE);
          final String nextIdString = nextId.toString(Character.MAX_RADIX);
          ZooSession.getSession().setData(ntp, nextIdString.getBytes(), stat.getVersion());
        } catch (Exception e1) {
          log.error("Failed to assign tableId to " + tableName, e1);
          throw new ThriftTableOperationException(tableId, tableName, TableOperation.CREATE, TableOperationExceptionType.OTHER, e1.getMessage());
        }
       
        // write tableName & tableId to zookeeper
        try {
          TableManager.getInstance().addTable(tableId, tableName);
          Tables.clearCache(instance);
        } catch (Exception e2) {
          log.error("Failed to create table " + tableName, e2);
          throw new ThriftTableOperationException(tableId, tableName, TableOperation.CREATE, TableOperationExceptionType.OTHER, e2.getMessage());
        }
      }
     
      for (Entry<String,String> entry : aggregators.entrySet()) {
        setTableProperty(null, SecurityConstants.systemCredentials, tableName, entry.getKey(), entry.getValue());
      }
     
      log.info(String.format("Creating table %s with tableId %s and %d splitPoints", tableName, tableId, splitPoints.size()));
      try {
        if (splitPoints.isEmpty()) {
          final Text tablet = null;
          final String dir = Constants.getTablesDir() + "/" + tableId;
          createNewTableTabletDirectories(fs, dir, Collections.singletonList(tablet));
         
          KeyExtent extent = new KeyExtent(new Text(tableId), null, null);
          MetadataTable.addTablet(extent, Constants.DEFAULT_TABLET_LOCATION, SecurityConstants.systemCredentials, TabletTime.getTimeID(timeType), masterLock);
          newly_created_tablets++;
        } else {
          Text previous = null;
          splitPoints.add(null);
         
          final ArrayList<Text> splitPointsText = new ArrayList<Text>(splitPoints.size());
         
          for (byte[] splitpoint : splitPoints) {
            if (splitpoint != null) {
              splitPointsText.add(new Text(splitpoint));
            } else {
              splitPointsText.add(null);
            }
          }
          final String dir = Constants.getTablesDir() + "/" + tableId;
          final Map<Text,String> tabletDirs = createNewTableTabletDirectories(fs, dir, splitPointsText);
         
          for (Text splitpointText : splitPointsText) {
            String datafiles = null;
            if (splitpointText != null) {
              datafiles = tabletDirs.get(splitpointText);
            } else {
              datafiles = Constants.DEFAULT_TABLET_LOCATION;
            }
           
            final KeyExtent local_newExtent = new KeyExtent(new Text(tableId), splitpointText, previous);
           
            fs.mkdirs(new Path(Constants.getTablesDir() + "/" + tableId + datafiles));
           
            MetadataTable.addTablet(local_newExtent, datafiles, SecurityConstants.systemCredentials, TabletTime.getTimeID(timeType), masterLock);
            previous = splitpointText;
            newly_created_tablets++;
          }
        }
       
      } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new ThriftTableOperationException(tableId, tableName, TableOperation.CREATE, TableOperationExceptionType.OTHER, e.getMessage());
      }
     
      // give all table permissions to the creator
      for (TablePermission permission : TablePermission.values()) {
        try {
View Full Code Here

       
        final Stat stat = new Stat();
        final String currentName = new String(ZooSession.getSession().getData(tap, false, stat));
       
        if (!currentName.equals(oldTableName)) {
          throw new ThriftTableOperationException(null, oldTableName, TableOperation.RENAME, TableOperationExceptionType.NOTFOUND,
              "Name changed while processing");
        }
        ZooSession.getSession().setData(tap, newTableName.getBytes(), stat.getVersion());
      } catch (Exception e) {
        log.warn("Rename failed ", e);
        throw new ThriftTableOperationException(null, newTableName, TableOperation.RENAME, TableOperationExceptionType.OTHER, e.getMessage());
      }
    }
View Full Code Here

        } else if (!TablePropUtil.setTableProperty(tableId, property, value)) {
          throw new Exception("Invalid table property.");
        }
      } catch (Exception e) {
        log.error("Problem altering table property", e);
        throw new ThriftTableOperationException(tableId, tableName, op, TableOperationExceptionType.OTHER, e.getMessage());
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException

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.