Exemplo n.º 1
0
  public String ac_set_control_$_1(Args args) {
    String mode = args.argv(0);
    String iString = args.getOpt("interval");
    long interval = 0L;
    if (iString != null) {
      interval = Long.parseLong(iString) * 1000L;
      if (interval < 30000L) {
        throw new IllegalArgumentException("interval must be greater than 30");
      }
    }

    switch (mode) {
      case "on":
        _flushController.setControl(true);
        break;
      case "off":
        _flushController.setControl(false);
        break;
      default:
        throw new IllegalArgumentException("set control on|off");
    }
    if (interval > 0L) {
      _queueWatch.setGainControlTicker(interval);
    }
    return "";
  }
Exemplo n.º 2
0
 public synchronized String ac_pp_interface_$_0_1(Args args) throws UnknownHostException {
   if (args.argc() == 1) {
     String host = args.argv(0);
     _interface = host.equals("*") ? null : InetAddress.getByName(host);
   }
   return "PP interface is " + getInterface();
 }
Exemplo n.º 3
0
 public String ac_whatToDo_$_1(Args args) {
   String domainName = args.argv(0);
   String serial = args.getOpt("serial");
   Map<String, HostAndPort> cores = coreDomains.cores();
   switch (cores.size()) {
     case 0:
       return null;
     case 1:
       String broker = Iterables.get(cores.keySet(), 0);
       return "do"
           + (serial != null ? " -serial=" + serial : "")
           + " "
           + domainName
           + " "
           + "nl"
           + " c:"
           + broker
           + " d:"
           + broker;
     default:
       LOGGER.warn(
           "Legacy domain {} tried to connect, but are not supported in multi-core topologies.",
           domainName);
       return "do" + (serial != null ? " -serial=" + serial : "") + " " + domainName;
   }
 }
Exemplo n.º 4
0
  private String startConnector(String remoteDomain, HostAndPort address)
      throws ExecutionException, InterruptedException {
    String cellName = "c-" + remoteDomain + "*";
    String clientKey = args.getOpt("clientKey");
    clientKey = (clientKey != null) && (clientKey.length() > 0) ? ("-clientKey=" + clientKey) : "";
    String clientName = args.getOpt("clientUserName");
    clientName =
        (clientName != null) && (clientName.length() > 0) ? ("-clientUserName="******"";

    String cellArgs =
        "-domain="
            + remoteDomain
            + " "
            + "-lm="
            + getCellName()
            + " "
            + "-role="
            + role
            + " "
            + "-where="
            + address
            + " "
            + clientKey
            + " "
            + clientName;
    LOGGER.info("Starting connector with {}", cellArgs);
    LocationManagerConnector c = new LocationManagerConnector(cellName, cellArgs);
    c.start().get();
    LOGGER.info("Created : {}", c);
    return c.getCellName();
  }
Exemplo n.º 5
0
 public synchronized String ac_pp_get_file_$_2(Args args)
     throws CacheException, IOException, InterruptedException {
   FileAttributes fileAttributes = new FileAttributes();
   fileAttributes.setPnfsId(new PnfsId(args.argv(0)));
   String pool = args.argv(1);
   List<StickyRecord> stickyRecords = Collections.emptyList();
   newCompanion(pool, fileAttributes, EntryState.CACHED, stickyRecords, null, false, null);
   return "Transfer Initiated";
 }
Exemplo n.º 6
0
 public String ac_driver_properties(Args args) {
   Map<String, String> map = new HashMap<>();
   for (int i = 0, n = args.optc(); i < n; i++) {
     String key = args.optv(i);
     String value = args.getOpt(key);
     map.put(key, value);
   }
   _eventDispatcher.propertiesUpdated(map);
   return "Properties sent to driver, check with 'info'";
 }
Exemplo n.º 7
0
  public String ac_check_osm_$_2(Args args) throws Exception {
    String store = args.argv(0);
    String bfid = args.argv(1);
    StorageInfo si = new OSMStorageInfo(store, "", bfid);

    getBfDetails(si);

    String result = si.getKey("hsm.details");

    return result == null ? "No Details" : result;
  }
Exemplo n.º 8
0
  public Object ac_ls_pool_$_0_1(Args args) {
    String poolName = args.argc() == 0 ? null : args.argv(0);
    boolean detail = args.hasOption("l");
    boolean binary = args.hasOption("binary");

    StringBuffer sb = new StringBuffer();
    if (poolName == null) {
      if (binary) {
        Collection<HsmFlushControlCore.PoolDetails> list = new ArrayList<>();
        for (Object pool : _eventDispatcher.getConfiguredPools()) {
          list.add(((HFCPool) pool).getDetails());
        }
        return list;
      } else {
        Set<String> set = new TreeSet<>(_poolCollector.getConfiguredPoolNames());
        for (Object configuredPoolName : set) {
          String name = configuredPoolName.toString();
          if (!detail) {
            sb.append(name).append("\n");
          } else {
            HFCPool pool = _poolCollector.getPoolByName(name);
            printPoolDetails2(pool, sb);
          }
        }
      }
    } else {
      HFCPool pool = _poolCollector.getPoolByName(poolName);
      if (pool == null) {
        throw new NoSuchElementException("Pool not found : " + poolName);
      }

      if (binary) {
        return pool.getDetails();
        /*
        HsmFlushControlCore.PoolDetails details = pool.getDetails() ;
        sb.append("PoolDetails\n").
           append("   Name ").append(details.getName()).append("\n").
           append("   CellInfo ").append(details.getCellInfo()).append("\n").
           append("   isActive ").append(details.isActive()).append("\n") ;
        for( Iterator i = details.getFlushInfos().iterator() ; i.hasNext() ; ){
           HsmFlushControlCore.FlushInfoDetails flush = (HsmFlushControlCore.FlushInfoDetails)i.next() ;
           sb.append("   StorageClass ").append(flush.getName()).append("\n").
              append("     isFlushing   ").append(flush.isFlushing()).append("\n").
              append("     FlushInfo    ").append(flush.getStorageClassFlushInfo()).append("\n");
        }
        */
      } else {
        printPoolDetails2(pool, sb);
      }
    }
    return sb.toString();
  }
Exemplo n.º 9
0
  public VspCheck1(String[] arg) throws Exception {
    Args args = new Args(arg);
    if (args.argc() < 1) {
      System.err.println("Usage : ...[options] <pnfsId1> [pnfsids ...]");
      System.err.println("      Options : [-host=<host>] [-port=<port>] [-parallel=<count>]");
      System.exit(4);
    }

    String tmp = args.getOpt("host");

    _host = tmp == null ? "localhost" : tmp;

    tmp = args.getOpt("port");
    tmp = tmp == null ? "22125" : tmp;
    _port = Integer.parseInt(tmp);

    tmp = args.getOpt("parallel");
    tmp = tmp == null ? "1" : tmp;
    _count = Integer.parseInt(tmp);

    _pnfsid = new String[args.argc()];
    for (int i = 0; i < args.argc(); i++) {
      _pnfsid[i] = args.argv(i);
    }

    for (int i = 0; i < _count; i++) {
      new WorkerThread(i).start();
    }
  }
Exemplo n.º 10
0
 public synchronized String ac_pp_remove_$_1(Args args) throws NumberFormatException {
   int id = Integer.valueOf(args.argv(0));
   if (!cancel(id)) {
     throw new IllegalArgumentException("Id not found: " + id);
   }
   return "";
 }
Exemplo n.º 11
0
 public String ac_listening_on_$_2(Args args) throws Exception {
   int port = Integer.parseInt(args.argv(1));
   HostAndPort address =
       HostAndPort.fromParts(InetAddress.getLocalHost().getCanonicalHostName(), port);
   coreDomains.setLocalAddress(address);
   return "";
 }
Exemplo n.º 12
0
  @Override
  protected void startUp() throws Exception {
    _poolManager = new CellStub(this, new CellPath("PoolManager"), 30, SECONDS);
    Args args = getArgs();
    checkArgument(args.argc() >= 1, "Usage : ... <pgroup0> [<pgroup1>[...]]");

    for (int i = 0, n = args.argc(); i < n; i++) {
      _poolGroupList.add(args.argv(0));
      args.shift();
    }
    String tmp = args.getOpt("scheduler");
    if ((tmp != null) && (!tmp.equals(""))) {
      _eventDispatcher.loadHandler(tmp, false, args);
    }

    _queueWatch = new QueueWatch();

    tmp = args.getOpt("poolCollectionUpdate");
    if ((tmp != null) && (!tmp.equals(""))) {
      try {
        _getPoolCollectionTicker = Long.parseLong(tmp) * 60L * 1000L;
      } catch (Exception ee) {
        _log.warn(
            "Illegal value for poolCollectionUpdate : {} (choosing {} millis)",
            tmp,
            _getPoolCollectionTicker);
      }
    }
    tmp = args.getOpt("gainControlUpdate");
    if ((tmp != null) && (!tmp.equals(""))) {
      long gainControlTicker = 0L;
      try {
        _queueWatch.setGainControlTicker(gainControlTicker = Long.parseLong(tmp) * 60L * 1000L);
      } catch (Exception ee) {
        _log.warn(
            "Illegal value for gainControlUpdate : {} (choosing {} millis)",
            tmp,
            gainControlTicker);
      }
    }
    tmp = args.getOpt("timer");
    if ((tmp != null) && (!tmp.equals(""))) {
      try {
        _timerInterval = Long.parseLong(tmp) * 1000L;
      } catch (Exception ee) {
        _log.warn("Illegal value for timer : {} (choosing {} millis)", tmp, _timerInterval);
      }
    }
    useInterpreter(true);
  }
Exemplo n.º 13
0
      public String ac_whereIs_$_1(Args args) {
        String domainName = args.argv(0);

        HostAndPort address = coreDomains.readAddressOf(domainName);
        if (address == null) {
          throw new IllegalArgumentException("Domain not listening: " + domainName);
        }

        StringBuilder sb = new StringBuilder();
        sb.append("location");
        String serial = args.getOpt("serial");
        if (serial != null) {
          sb.append(" -serial=").append(serial);
        }
        sb.append(" ").append(domainName);
        sb.append(" ").append(address);
        return sb.toString();
      }
Exemplo n.º 14
0
  private void _loadShells(Args args) {
    Object[][] objList = new Object[_signature.length][];
    for (int i = 0; i < objList.length; i++) {
      objList[i] = new Object[_signature[i].length];
    }

    objList[0][0] = _subject;
    objList[0][1] = getNucleus();
    objList[0][2] = new Args(args);
    objList[1][0] = getNucleus();

    Class<?> c;
    Constructor<?> con = null;
    Object o;
    for (int i = 0; i < args.argc(); i++) {
      _log.info("Trying to load shell : " + args.argv(i));
      try {
        c = Class.forName(args.argv(i));
        int j;
        for (j = 0; j < _signature.length; j++) {
          try {
            con = c.getConstructor(_signature[j]);
            break;
          } catch (Exception e) {

          }
        }
        if (j == _signature.length) {
          throw new Exception("No constructor found");
        }

        o = con.newInstance(objList[j]);
        addCommandListener(o);
        _log.info("Added : " + args.argv(i));
      } catch (Exception ee) {
        _log.warn("Failed to load shell : " + args.argv(i) + " : " + ee);
        if (ee instanceof InvocationTargetException) {
          _log.warn(
              "   -> Problem in constructor : "
                  + ((InvocationTargetException) ee).getTargetException());
        }
      }
    }
  }
Exemplo n.º 15
0
    public void process(DatagramPacket packet) throws Exception {
      byte[] data = packet.getData();
      int datalen = packet.getLength();
      InetAddress address = packet.getAddress();
      if (datalen <= 0) {
        LOGGER.warn("Empty Packet arrived from {}", packet.getAddress());
        return;
      }
      String message = new String(data, 0, datalen);
      LOGGER.info("server query : [{}] ({}) {}", address, message.length(), message);
      Args args = new Args(message);
      message = (args.argc() == 0) ? "" : (String) remoteCommands.command(args);

      if (message != null) {
        LOGGER.info("server reply : {}", message);
        data = message.getBytes();
        packet.setData(data);
        packet.setLength(data.length);
      }
    }
Exemplo n.º 16
0
  public String ac_query_pool_mode_$_1(Args args) {
    String poolName = args.argv(0);

    HFCPool pool = _poolCollector.getPoolByName(poolName);
    if (pool == null) {
      throw new NoSuchElementException("Pool not found : " + poolName);
    }

    pool.queryMode();

    return "Pool mode query sent to Pool " + poolName;
  }
Exemplo n.º 17
0
  public String ac_flush_pool_$_2(Args args) throws Exception {
    String poolName = args.argv(0);
    String storageClass = args.argv(1);
    String countString = args.getOpt("count");

    int count = (countString == null) || countString.equals("") ? 0 : Integer.parseInt(countString);

    HFCPool pool = _poolCollector.getPoolByName(poolName);
    if (pool == null) {
      throw new NoSuchElementException("Pool not found : " + poolName);
    }

    HsmFlushControlCore.FlushInfo info = pool.getFlushInfoByStorageClass(storageClass);
    if (info == null) {
      throw new NoSuchElementException("StorageClass not found : " + storageClass);
    }

    info.flush(count);

    return "Flush initiated for (" + poolName + "," + storageClass + ")";
  }
Exemplo n.º 18
0
  public GFtpProtocol_2_nio(CellEndpoint cell) {
    _cell = cell;

    String range = System.getProperty("org.globus.tcp.port.range");
    if (range != null) {
      _portRange = PortRange.valueOf(range);
    } else {
      _portRange = new PortRange(0);
    }

    if (_cell != null) {
      Args args = _cell.getArgs();
      if (args.hasOption("ftpProxyPassive")) {
        _allowPassivePool = !Boolean.parseBoolean(args.getOpt("ftpProxyPassive"));
      }

      if (args.hasOption("gsiftpBlockSize")) {
        _blockSize = Integer.valueOf(args.getOpt("gsiftpBlockSize"));
      }
    }
  }
Exemplo n.º 19
0
  public String ac_set_pool_$_2(Args args) {
    String poolName = args.argv(0);
    String mode = args.argv(1);

    HFCPool pool = _poolCollector.getPoolByName(poolName);
    if (pool == null) {
      throw new NoSuchElementException("Pool not found : " + poolName);
    }

    switch (mode) {
      case "rdonly":
        pool.setReadOnly(true);
        break;
      case "rw":
        pool.setReadOnly(false);
        break;
      default:
        throw new IllegalArgumentException("Illegal mode : rdonly|rw");
    }

    return "Pool " + poolName + " set to " + mode;
  }
Exemplo n.º 20
0
  public HsmControlOsm(String name, String args) throws Exception {
    super(name, args, false);
    _nucleus = getNucleus();
    _args = getArgs();
    try {
      if (_args.argc() < 1) {
        throw new IllegalArgumentException("Usage : ... <database>");
      }

      _database = new File(_args.argv(0));
      if (!_database.isDirectory()) {
        throw new IllegalArgumentException("Not a directory : " + _database);
      }
    } catch (Exception e) {
      start();
      kill();
      throw e;
    }
    useInterpreter(true);
    _nucleus.newThread(this, "queueWatch").start();
    start();
    export();
  }
Exemplo n.º 21
0
  public String ac_define_driver_$_2(Args args) throws Exception {

    String hsm = args.argv(0);
    String driver = args.argv(1);
    Class<?> c = Class.forName(driver);
    Class<?>[] classArgs = {Args.class, Args.class};
    Object[] objectArgs = {getArgs(), args, this};

    Constructor<?> con = c.getConstructor(classArgs);
    Object[] values = new Object[3];
    try {
      values[0] = driver;
      values[1] = con.newInstance(objectArgs);
      values[2] = args;
    } catch (InvocationTargetException ite) {
      throw (Exception) ite.getTargetException();
    }
    if (!(values[1] instanceof HsmControllable)) {
      throw new IllegalArgumentException("Not a HsmControllable : (" + hsm + ") " + driver);
    }

    _driverMap.put(hsm, values);
    return hsm + " " + driver + " " + values[1].toString();
  }
Exemplo n.º 22
0
 public synchronized String ac_pp_set_pnfs_timeout_$_1(Args args) {
   long timeout = Long.parseLong(args.argv(0));
   _pnfs.setTimeout(timeout);
   _pnfs.setTimeoutUnit(TimeUnit.SECONDS);
   return "Pnfs timeout set to " + timeout + " seconds";
 }
Exemplo n.º 23
0
 /** Returns the value of an option, or a default value if the option has not been set. */
 public static String getOption(Args args, String name, String defaultValue) {
   String value = args.getOpt(name);
   return value == null ? defaultValue : value;
 }
Exemplo n.º 24
0
  /** Test program for this class. */
  public static void main(String a[]) {
    try {
      Args args = new Args(a);
      int port = Integer.valueOf(getOption(args, "port", "2288"));
      int bufferSize = Integer.valueOf(getOption(args, "buffer", "0"));
      int parallelism = Integer.valueOf(getOption(args, "streams", "1"));
      long offset = Long.valueOf(getOption(args, "offset", "0"));
      long size = Long.valueOf(getOption(args, "size", "0"));
      String digest = getOption(args, "digest", "");
      boolean verbose = Boolean.valueOf(getOption(args, "verbose", "false"));

      Role role = Role.Receiver;
      if (args.isOneCharOption('r')) {
        role = Role.Receiver;
      } else if (args.isOneCharOption('s')) {
        role = Role.Sender;
      } else {
        help();
      }

      GFtpProtocol_2_nio mover = new GFtpProtocol_2_nio(null);

      RepositoryChannel fileChannel =
          new FileRepositoryChannel(args.argv(0), role == Role.Sender ? "r" : "rw");

      Mode mode = mover.createMode(getOption(args, "mode", "S"), role, fileChannel);

      if (args.isOneCharOption('l')) {
        if (args.argc() != 1) {
          help();
        }
        ServerSocketChannel channel = ServerSocketChannel.open();
        if (bufferSize > 0) {
          channel.socket().setReceiveBufferSize(bufferSize);
        }
        channel.socket().bind(new InetSocketAddress(port));
        mode.setPassive(channel);
      } else {
        if (args.argc() != 2) {
          help();
        }
        mode.setActive(new InetSocketAddress(args.argv(1), port));
      }

      if (digest.length() > 0 && role != Role.Receiver) {
        System.err.println("Digest can only be computed on receive");
        System.exit(1);
      }

      if (size == 0) {
        size = fileChannel.size() - offset;
      }

      mode.setParallelism(parallelism);
      mode.setPartialRetrieveParameters(offset, size);

      if (digest.length() > 0) {
        mover.enableTransferChecksum(ChecksumType.getChecksumType(digest));
      }

      mover.setVerboseLogging(verbose);
      mover.transfer(fileChannel, role, mode, null);
      if (digest.length() > 0) {
        System.out.println(mover.getActualChecksum());
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
Exemplo n.º 25
0
 public String ac_load_driver_$_999(Args args) throws Exception {
   String driverClass = args.argv(0);
   args.shift();
   _eventDispatcher.loadHandler(driverClass, true, args);
   return "Loaded : " + driverClass;
 }
Exemplo n.º 26
0
 public synchronized String ac_pp_set_max_active_$_1(Args args) {
   _maxActive = Integer.parseInt(args.argv(0));
   return "";
 }
Exemplo n.º 27
0
 public String ac_pgroup_remove_$_1_99(Args args) {
   for (int i = 0; i < args.argc(); i++) {
     _poolGroupList.remove(args.argv(i));
   }
   return "";
 }
Exemplo n.º 28
0
 public synchronized String ac_pp_set_listen_$_1_2(Args args) throws UnknownHostException {
   return ac_pp_interface_$_0_1(new Args(args.argv(0)));
 }