Examples of VolumeManager


Examples of es.ipsa.atril.doc.volumes.VolumeManager

  public Volume getVolume(AtrilSession oSes) throws ElementNotFoundException {
    if (oDoc==null) {
      return null;
    } else {
      VolumeManager oVolm = oSes.getDms().getVolumeManager();
      if (oVolm.hasVolume(oDoc))
        return oVolm.getVolume(oDoc);
      else
        return null;
    }     
  }
View Full Code Here

Examples of es.ipsa.atril.doc.volumes.VolumeManager

    final String sRepositoryFullPath = Gadgets.chomp(sVolumesMountBase,File.separator)+sVolumeSubpath+File.separator+sRepositorySubpath;
    Log.out.debug("FileSystem.mkdirs(file://"+sRepositoryFullPath+")");
    oFs.mkdirs("file://"+sRepositoryFullPath);
    File oFl = new File(sRepositoryFullPath);
    if (!oFl.exists()) throw new FileNotFoundException("Could not create directory "+sRepositoryFullPath);
    VolumeManager oVolm = oDms.getVolumeManager();
    Log.out.debug("VolumeManager.createVolume("+sVolumeName+","+Gadgets.chomp(sVolumesMountBase,File.separator)+sVolumeSubpath+File.separator+","+sRepositorySubpath+","+String.valueOf(iMaxDocSize)+")");
    Volume oVol = oVolm.createVolume(sVolumeName, Gadgets.chomp(sVolumesMountBase,File.separator)+sVolumeSubpath+File.separator, sRepositorySubpath, iMaxDocSize);
    oVol.setTotalSpace(lTotalSpace);
    oVol.setMaxFiles(65535);
    oVol.setMaxDirectories(65535);
    oVol.addDocument(getDocument());
    oVol.save();
View Full Code Here

Examples of es.ipsa.atril.doc.volumes.VolumeManager

  public Volume getVolume(AtrilSession oSes) throws ElementNotFoundException {
    Document oDoc = getDocument();
    if (oDoc==null) {
      return null;
    } else {
      VolumeManager oVolm = oSes.getDms().getVolumeManager();
      if (oVolm.hasVolume(oDoc))
        return oVolm.getVolume(oDoc);
      else {
        Document oTxp = oSes.getDms().getDocument(getTaxPayer());
        if (oVolm.hasVolume(oTxp))
          return oVolm.getVolume(oTxp);
        else
          return null;       
      }
    }     
  }
View Full Code Here

Examples of es.ipsa.atril.doc.volumes.VolumeManager

    oSess.commit();

    String sMountBase = "/usr/local/apache-tomcat-6.0.36/webapps/zesped/WEB-INF/volumes/"; // DAO.getVolumesMountBase();
    if (sMountBase.length()>0) {
      boolean bDefaultVolumeExists = false;
      VolumeManager oVolm = oDms.getVolumeManager();
      for (Volume v : oVolm.getVolumeList()) {
        bDefaultVolumeExists = v.name().equals("Default");
        if (bDefaultVolumeExists) break;
      }
      if (!bDefaultVolumeExists) {
        sMountBase = Gadgets.chomp(sMountBase, File.separator);
          FileSystem oFs = new FileSystem();
          try {
        oFs.mkdirs("file://"+sMountBase+"default");
      } catch (Exception e) {
        throw new FileNotFoundException("Could not create directory "+sMountBase+"default");
      }
          if (!new File(sMountBase).exists()) throw new FileNotFoundException("Could not create directory "+sMountBase+"default");
          Volume oVol = oVolm.createVolume("Default", sMountBase, "default", 20*1048576);
          oVol.setTotalSpace(100*1048576);
          oVol.setDescription("Default Zesped Volume");
          oVol.setMounted(true);
          oVol.setUsable(true);
          oVol.setMaxDirectories(1000);
View Full Code Here

Examples of es.ipsa.atril.doc.volumes.VolumeManager

      Document dCts = oDms.newDocument(oDms.getDocumentType("CaptureTypes"), oDms.getRootDocument());
      dCts.save("");
      oUsrsGrp.grantReadOnly(dCts);
      oOpersGrp.grantReadOnly(dCts);
      oSes.commit();
      VolumeManager oVolm = oDms.getVolumeManager();
      Volume oVol = DAO.defaultVolume(oVolm);
      oVol.addDocument(dCts);
      oVol.save();
      oSes.commit();
      oCts = new CaptureTypes(dCts);
View Full Code Here

Examples of org.apache.accumulo.server.fs.VolumeManager

  public synchronized void open(String address) throws IOException {
    String filename = UUID.randomUUID().toString();
    String logger = StringUtil.join(Arrays.asList(address.split(":")), "+");

    log.debug("DfsLogger.open() begin");
    VolumeManager fs = conf.getFileSystem();

    logPath = fs.choose(ServerConstants.getWalDirs()) + "/" + logger + "/" + filename;
    metaReference = toString();
    try {
      short replication = (short) conf.getConfiguration().getCount(Property.TSERV_WAL_REPLICATION);
      if (replication == 0)
        replication = fs.getDefaultReplication(new Path(logPath));
      long blockSize = conf.getConfiguration().getMemoryInBytes(Property.TSERV_WAL_BLOCKSIZE);
      if (blockSize == 0)
        blockSize = (long) (conf.getConfiguration().getMemoryInBytes(Property.TSERV_WALOG_MAX_SIZE) * 1.1);
      if (conf.getConfiguration().getBoolean(Property.TSERV_WAL_SYNC))
        logFile = fs.createSyncable(new Path(logPath), 0, replication, blockSize);
      else
        logFile = fs.create(new Path(logPath), true, 0, replication, blockSize);

      String syncMethod = conf.getConfiguration().get(Property.TSERV_WAL_SYNC_METHOD);
      try {
        // hsync: send data to datanodes and sync the data to disk
        sync = logFile.getClass().getMethod(syncMethod);
View Full Code Here

Examples of org.apache.accumulo.server.fs.VolumeManager

  }

  public static void main(String[] args) throws IOException {
    try {
      SecurityUtil.serverLogin(ServerConfiguration.getSiteConfiguration());
      VolumeManager fs = VolumeManagerImpl.get();
      ServerOpts opts = new ServerOpts();
      opts.parseArgs("tserver", args);
      String hostname = opts.getAddress();
      Instance instance = HdfsZooInstance.getInstance();
      ServerConfiguration conf = new ServerConfiguration(instance);
View Full Code Here

Examples of org.apache.accumulo.server.fs.VolumeManager

    log.debug(" tid " + tid + " sourceDir " + sourceDir);

    Utils.getReadLock(tableId, tid).lock();

    // check that the error directory exists and is empty
    VolumeManager fs = master.getFileSystem();

    Path errorPath = new Path(errorDir);
    FileStatus errorStatus = null;
    try {
      errorStatus = fs.getFileStatus(errorPath);
    } catch (FileNotFoundException ex) {
      // ignored
    }
    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);
View Full Code Here

Examples of org.apache.accumulo.server.fs.VolumeManager

  @Override
  public Repo<Master> call(long tid, Master master) throws Exception {
    // This needs to execute after the arbiter is stopped

    VolumeManager fs = master.getFileSystem();

    if (!fs.exists(new Path(error, BulkImport.FAILURES_TXT)))
      return new CleanUpBulkImport(tableId, source, bulk, error);

    HashMap<FileRef,String> failures = new HashMap<FileRef,String>();
    HashMap<FileRef,String> loadedFailures = new HashMap<FileRef,String>();

    FSDataInputStream failFile = fs.open(new Path(error, BulkImport.FAILURES_TXT));
    BufferedReader in = new BufferedReader(new InputStreamReader(failFile, Constants.UTF8));
    try {
      String line = null;
      while ((line = in.readLine()) != null) {
        Path path = new Path(line);
        if (!fs.exists(new Path(error, path.getName())))
          failures.put(new FileRef(line, path), line);
      }
    } finally {
      failFile.close();
    }

    /*
     * I thought I could move files that have no file references in the table. However its possible a clone references a file. Therefore only move files that
     * have no loaded markers.
     */

    // determine which failed files were loaded
    Connector conn = master.getConnector();
    Scanner mscanner = new IsolatedScanner(conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY));
    mscanner.setRange(new KeyExtent(new Text(tableId), null, null).toMetadataRange());
    mscanner.fetchColumnFamily(TabletsSection.BulkFileColumnFamily.NAME);

    for (Entry<Key,Value> entry : mscanner) {
      if (Long.parseLong(entry.getValue().toString()) == tid) {
        FileRef loadedFile = new FileRef(fs, entry.getKey());
        String absPath = failures.remove(loadedFile);
        if (absPath != null) {
          loadedFailures.put(loadedFile, absPath);
        }
      }
    }

    // move failed files that were not loaded
    for (String failure : failures.values()) {
      Path orig = new Path(failure);
      Path dest = new Path(error, orig.getName());
      fs.rename(orig, dest);
      log.debug("tid " + tid + " renamed " + orig + " to " + dest + ": import failed");
    }

    if (loadedFailures.size() > 0) {
      DistributedWorkQueue bifCopyQueue = new DistributedWorkQueue(Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
          + Constants.ZBULK_FAILED_COPYQ);

      HashSet<String> workIds = new HashSet<String>();

      for (String failure : loadedFailures.values()) {
        Path orig = new Path(failure);
        Path dest = new Path(error, orig.getName());

        if (fs.exists(dest))
          continue;

        bifCopyQueue.addWork(orig.getName(), (failure + "," + dest).getBytes(Constants.UTF8));
        workIds.add(orig.getName());
        log.debug("tid " + tid + " added to copyq: " + orig + " to " + dest + ": failed");
      }

      bifCopyQueue.waitUntilDone(workIds);
    }

    fs.deleteRecursively(new Path(error, BulkImport.FAILURES_TXT));
    return new CleanUpBulkImport(tableId, source, bulk, error);
  }
View Full Code Here

Examples of org.apache.accumulo.server.fs.VolumeManager

  @Override
  public Repo<Master> call(final long tid, final Master master) throws Exception {
    ExecutorService executor = getThreadPool(master);
    final SiteConfiguration conf = ServerConfiguration.getSiteConfiguration();
    VolumeManager fs = master.getFileSystem();
    List<FileStatus> files = new ArrayList<FileStatus>();
    for (FileStatus entry : fs.listStatus(new Path(bulk))) {
      files.add(entry);
    }
    log.debug("tid " + tid + " importing " + files.size() + " files");

    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);
      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);

    final Set<String> filesToLoad = Collections.synchronizedSet(new HashSet<String>());
    for (FileStatus f : files)
      filesToLoad.add(f.getPath().toString());

    final int RETRIES = Math.max(1, conf.getCount(Property.MASTER_BULK_RETRIES));
    for (int attempt = 0; attempt < RETRIES && filesToLoad.size() > 0; attempt++) {
      List<Future<List<String>>> results = new ArrayList<Future<List<String>>>();

      if (master.onlineTabletServers().size() == 0)
        log.warn("There are no tablet server to process bulk import, waiting (tid = " + tid + ")");

      while (master.onlineTabletServers().size() == 0) {
        UtilWaitThread.sleep(500);
      }

      // Use the threadpool to assign files one-at-a-time to the server
      final List<String> loaded = Collections.synchronizedList(new ArrayList<String>());
      for (final String file : filesToLoad) {
        results.add(executor.submit(new Callable<List<String>>() {
          @Override
          public List<String> call() {
            List<String> failures = new ArrayList<String>();
            ClientService.Client client = null;
            String server = null;
            try {
              // get a connection to a random tablet server, do not prefer cached connections because
              // this is running on the master and there are lots of connections to tablet servers
              // serving the metadata tablets
              long timeInMillis = master.getConfiguration().getConfiguration().getTimeInMillis(Property.MASTER_BULK_TIMEOUT);
              Pair<String,Client> pair = ServerClient.getConnection(master.getInstance(), false, timeInMillis);
              client = pair.getSecond();
              server = pair.getFirst();
              List<String> attempt = Collections.singletonList(file);
              log.debug("Asking " + pair.getFirst() + " to bulk import " + file);
              List<String> fail = client.bulkImportFiles(Tracer.traceInfo(), SystemCredentials.get().toThrift(master.getInstance()), tid, tableId, attempt,
                  errorDir, setTime);
              if (fail.isEmpty()) {
                loaded.add(file);
              } else {
                failures.addAll(fail);
              }
            } catch (Exception ex) {
              log.error("rpc failed server:" + server + ", tid:" + tid + " " + ex);
            } finally {
              ServerClient.close(client);
            }
            return failures;
          }
        }));
      }
      Set<String> failures = new HashSet<String>();
      for (Future<List<String>> f : results)
        failures.addAll(f.get());
      filesToLoad.removeAll(loaded);
      if (filesToLoad.size() > 0) {
        log.debug("tid " + tid + " attempt " + (attempt + 1) + " " + sampleList(filesToLoad, 10) + " failed");
        UtilWaitThread.sleep(100);
      }
    }

    FSDataOutputStream failFile = fs.create(new Path(errorDir, BulkImport.FAILURES_TXT), true);
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(failFile, Constants.UTF8));
    try {
      for (String f : filesToLoad) {
        out.write(f);
        out.write("\n");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.