Beispiel #1
1
  private String createUniqueFilename(String path) {
    String random = "" + System.nanoTime();

    // just use the last 16 numbers
    if (random.length() > 16) random = random.substring(random.length() - 16);

    random += "" + new Random(System.currentTimeMillis()).nextInt(10000);

    return path + "\\DELETE_ME_" + random;
  }
Beispiel #2
0
  /*
   * BE CAREFUL -- Don't introduce "Distributed Concurrency Bugs"
   * e.g. you have to make sure the filename is unique.
   * 1. create a remote file
   * 2. copy the token/auth stuff into it
   * 3. add the correct args to the remote commandline
   *    Put the file in the same directory that nadmin lives in (lib)
   */
  private void setupAuthTokenFile(List<String> cmd, List<String> stdin) throws WindowsException {
    WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(dcomInfo.getCredentials());
    authTokenFilePath =
        dcomInfo.getNadminParentPath()
            + "\\token_"
            + System.nanoTime()
            + new Random().nextInt(1000);
    authTokenFilePath = createUniqueFilename(dcomInfo.getNadminParentPath());
    authTokenFile = new WindowsRemoteFile(wrfs, authTokenFilePath);
    authTokenFile.copyFrom(stdin);

    cmd.add(AsadminInput.CLI_INPUT_OPTION);
    cmd.add(authTokenFilePath);
  }
Beispiel #3
0
  @Override
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    Object res = null;

    {
      long t0 = System.nanoTime();

      try {
        res = method.invoke(resource, args);
      } catch (InvocationTargetException ex) {
        throw ex.getTargetException();
      } catch (Exception ex) {
        throw ex;
      } finally {
        long t1 = System.nanoTime();
        long t = t1 - t0;

        log(method, args, t);
      }
    }

    return res;
  }