public static void main(String args[]) throws Exception {
    // cache the initial set of loggers before this test begins
    // to add any loggers
    Enumeration<String> e = logMgr.getLoggerNames();
    List<String> defaultLoggers = getDefaultLoggerNames();
    while (e.hasMoreElements()) {
      String logger = e.nextElement();
      if (!defaultLoggers.contains(logger)) {
        initialLoggerNames.add(logger);
      }
    }
    ;

    String tstSrc = System.getProperty(TST_SRC_PROP);
    File fname = new File(tstSrc, LM_PROP_FNAME);
    String prop = fname.getCanonicalPath();
    System.setProperty(CFG_FILE_PROP, prop);
    logMgr.readConfiguration();

    System.out.println();
    if (checkLoggers() == PASSED) {
      System.out.println(MSG_PASSED);
    } else {
      System.out.println(MSG_FAILED);
      throw new Exception(MSG_FAILED);
    }
  }
  /**
   * Creates a new Socket connected to the given IP address. The method uses connection settings
   * supplied in the constructor for connecting the socket.
   *
   * @param address the IP address to connect to
   * @return connected socket
   * @throws java.net.UnknownHostException if the hostname of the address or the proxy cannot be
   *     resolved
   * @throws java.io.IOException if an I/O error occured while connecting to the remote end or to
   *     the proxy
   */
  private Socket createSocket(InetSocketAddress address, int timeout) throws IOException {
    String socksProxyHost = System.getProperty("socksProxyHost");
    System.getProperties().remove("socksProxyHost");
    try {
      ConnectivitySettings cs = lastKnownSettings.get(address);
      if (cs != null) {
        try {
          return createSocket(cs, address, timeout);
        } catch (IOException e) {
          // not good anymore, try all proxies
          lastKnownSettings.remove(address);
        }
      }

      URI uri = addressToURI(address, "socket");
      try {
        return createSocket(uri, address, timeout);
      } catch (IOException e) {
        // we will also try https
      }

      uri = addressToURI(address, "https");
      return createSocket(uri, address, timeout);

    } finally {
      if (socksProxyHost != null) {
        System.setProperty("socksProxyHost", socksProxyHost);
      }
    }
  }
Esempio n. 3
0
  public static void testNSS(PKCS11Test test) throws Exception {
    if (!(new File(NSS_BASE)).exists()) return;

    String libdir = getNSSLibDir();
    if (libdir == null) {
      return;
    }

    if (loadNSPR(libdir) == false) {
      return;
    }

    String libfile = libdir + System.mapLibraryName("softokn3");

    String customDBdir = System.getProperty("CUSTOM_DB_DIR");
    String dbdir = (customDBdir != null) ? customDBdir : NSS_BASE + SEP + "db";
    // NSS always wants forward slashes for the config path
    dbdir = dbdir.replace('\\', '/');

    String customConfig = System.getProperty("CUSTOM_P11_CONFIG");
    String customConfigName = System.getProperty("CUSTOM_P11_CONFIG_NAME", "p11-nss.txt");
    String p11config = (customConfig != null) ? customConfig : NSS_BASE + SEP + customConfigName;

    System.setProperty("pkcs11test.nss.lib", libfile);
    System.setProperty("pkcs11test.nss.db", dbdir);
    Provider p = getSunPKCS11(p11config);
    test.premain(p);
  }
Esempio n. 4
0
  static {
    System.setProperty("svnkit.log.native.calls", "true");
    final JavaSVNDebugLogger logger =
        new JavaSVNDebugLogger(
            Boolean.getBoolean(LOG_PARAMETER_NAME), Boolean.getBoolean(TRACE_NATIVE_CALLS), LOG);
    SVNDebugLog.setDefaultLog(logger);

    SVNJNAUtil.setJNAEnabled(true);
    SvnHttpAuthMethodsDefaultChecker.check();

    SVNAdminAreaFactory.setSelector(new SvnFormatSelector());

    DAVRepositoryFactory.setup();
    SVNRepositoryFactoryImpl.setup();
    FSRepositoryFactory.setup();

    // non-optimized writing is fast enough on Linux/MacOS, and somewhat more reliable
    if (SystemInfo.isWindows) {
      SVNAdminArea14.setOptimizedWritingEnabled(true);
    }

    if (!SVNJNAUtil.isJNAPresent()) {
      LOG.warn("JNA is not found by svnkit library");
    }
    initLogFilters();

    // Alexander Kitaev says it is default value (SSLv3) - since 8254
    if (!SystemInfo.JAVA_RUNTIME_VERSION.startsWith("1.7")
        && System.getProperty(SVNKIT_HTTP_SSL_PROTOCOLS) == null) {
      System.setProperty(SVNKIT_HTTP_SSL_PROTOCOLS, "SSLv3");
    }
  }
Esempio n. 5
0
  protected static void initSystemProperties(MoquiStart cl, boolean useProperties)
      throws IOException {
    Properties moquiInitProperties = new Properties();
    URL initProps = cl.getResource("MoquiInit.properties");
    if (initProps != null) {
      InputStream is = initProps.openStream();
      moquiInitProperties.load(is);
      is.close();
    }

    // before doing anything else make sure the moqui.runtime system property exists (needed for
    // config of various things)
    String runtimePath = System.getProperty("moqui.runtime");
    if (runtimePath != null && runtimePath.length() > 0)
      System.out.println("Determined runtime from system property: " + runtimePath);
    if (useProperties && (runtimePath == null || runtimePath.length() == 0)) {
      runtimePath = moquiInitProperties.getProperty("moqui.runtime");
      if (runtimePath != null && runtimePath.length() > 0)
        System.out.println("Determined runtime from MoquiInit.properties file: " + runtimePath);
    }
    if (runtimePath == null || runtimePath.length() == 0) {
      // see if runtime directory under the current directory exists, if not default to the current
      // directory
      File testFile = new File("runtime");
      if (testFile.exists()) runtimePath = "runtime";
      if (runtimePath != null && runtimePath.length() > 0)
        System.out.println("Determined runtime from existing runtime directory: " + runtimePath);
    }
    if (runtimePath == null || runtimePath.length() == 0) {
      runtimePath = ".";
      System.out.println("Determined runtime by defaulting to current directory: " + runtimePath);
    }
    File runtimeFile = new File(runtimePath);
    runtimePath = runtimeFile.getCanonicalPath();
    System.out.println("Canonicalized runtimePath: " + runtimePath);
    if (runtimePath.endsWith("/")) runtimePath = runtimePath.substring(0, runtimePath.length() - 1);
    System.setProperty("moqui.runtime", runtimePath);

    /* Don't do this here... loads as lower-level that WEB-INF/lib jars and so can't have dependencies on those,
        and dependencies on those are necessary
    // add runtime/lib jar files to the class loader
    File runtimeLibFile = new File(runtimePath + "/lib");
    for (File jarFile: runtimeLibFile.listFiles()) {
        if (jarFile.getName().endsWith(".jar")) cl.jarFileList.add(new JarFile(jarFile));
    }
    */

    // moqui.conf=conf/development/MoquiDevConf.xml
    String confPath = System.getProperty("moqui.conf");
    if (confPath == null || confPath.length() == 0) {
      confPath = moquiInitProperties.getProperty("moqui.conf");
    }
    if (confPath == null || confPath.length() == 0) {
      File testFile = new File(runtimePath + "/" + defaultConf);
      if (testFile.exists()) confPath = defaultConf;
    }
    if (confPath != null) System.setProperty("moqui.conf", confPath);
  }
 static {
   verbose = true; // Boolean.getBoolean("test.get.file.while.closing.project.verbose");
   if (verbose) {
     System.setProperty("cnd.modelimpl.timing", "true");
     System.setProperty("cnd.modelimpl.timing.per.file.flat", "true");
     System.setProperty("cnd.repository.listener.trace", "true");
     System.setProperty("cnd.trace.close.project", "true");
     System.setProperty("cnd.repository.workaround.nulldata", "true");
   }
 }
Esempio n. 7
0
 public void refreshSSLProperty() {
   if (ourSSLProtocolsExplicitlySet) return;
   if (SvnConfiguration.SSLProtocols.all.equals(myConfiguration.SSL_PROTOCOLS)) {
     System.clearProperty(SVNKIT_HTTP_SSL_PROTOCOLS);
   } else if (SvnConfiguration.SSLProtocols.sslv3.equals(myConfiguration.SSL_PROTOCOLS)) {
     System.setProperty(SVNKIT_HTTP_SSL_PROTOCOLS, "SSLv3");
   } else if (SvnConfiguration.SSLProtocols.tlsv1.equals(myConfiguration.SSL_PROTOCOLS)) {
     System.setProperty(SVNKIT_HTTP_SSL_PROTOCOLS, "TLSv1");
   }
 }
  @Override
  public void open() {
    logger.info(
        "Starting Tachyon shell to connect to "
            + tachyonMasterHostname
            + " on port "
            + tachyonMasterPort);

    System.setProperty(TACHYON_MASTER_HOSTNAME, tachyonMasterHostname);
    System.setProperty(TACHYON_MASTER_PORT, tachyonMasterPort);
    tfs = new TfsShell(new TachyonConf());
  }
  private int attemptPrecompiledScriptExecute(
      CommandLine commandLine,
      String scriptName,
      String env,
      GantBinding binding,
      List<File> allScripts) {
    console.updateStatus("Running pre-compiled script");

    // Must be called before the binding is initialised.
    setRunningEnvironment(commandLine, env);

    // Get Gant to load the class by name using our class loader.
    ScriptBindingInitializer bindingInitializer =
        new ScriptBindingInitializer(
            commandLine, classLoader, settings, pluginPathSupport, isInteractive);
    Gant gant = new Gant(bindingInitializer.initBinding(binding, scriptName), classLoader);

    try {
      loadScriptClass(gant, scriptName);
    } catch (ScriptNotFoundException e) {
      if (!isInteractive || InteractiveMode.isActive()) {
        throw e;
      }
      scriptName = fixScriptName(scriptName, allScripts);
      if (scriptName == null) {
        throw e;
      }

      try {
        loadScriptClass(gant, scriptName);
      } catch (ScriptNotFoundException ce) {
        return executeScriptWithCaching(commandLine, scriptName, env);
      }

      // at this point if they were calling a script that has a non-default
      // env (e.g. war or test-app) it wouldn't have been correctly set, so
      // set it now, but only if they didn't specify the env (e.g. "grails test war" -> "grails test
      // war")

      if (Boolean.TRUE.toString().equals(System.getProperty(Environment.DEFAULT))) {
        commandLine.setCommand(GrailsNameUtils.getScriptName(scriptName));
        env = commandLine.lookupEnvironmentForCommand();
        binding.setVariable("grailsEnv", env);
        settings.setGrailsEnv(env);
        System.setProperty(Environment.KEY, env);
        settings.setDefaultEnv(false);
        System.setProperty(Environment.DEFAULT, Boolean.FALSE.toString());
      }
    }

    return executeWithGantInstance(gant, DO_NOTHING_CLOSURE, binding).exitCode;
  }
  public void init(FilterConfig config) throws ServletException {

    Log log = LogFactory.getLog(this.getClass());
    log.info("PsqStoreConfigFilter: init(config) called");

    String path = "";

    try {
      URL pathUrl = config.getServletContext().getResource("/");

      path = new File(config.getServletContext().getRealPath("/")).getAbsolutePath();

      log.info(" protocol=" + pathUrl.getProtocol());
      log.info(" path=" + path);

    } catch (Exception ex) {
      ex.printStackTrace();
    }

    if (config.getInitParameter("derby-home") != null) {

      String myHome = config.getInitParameter("derby-home");
      if (!myHome.startsWith("/")) {
        myHome = path + File.separator + myHome;
      }

      log.info("derby-home(final)=" + myHome);
      System.setProperty("xpsq.derby.home", myHome);

      if (PsqContext.getStore("derby") != null) {
        PsqContext.getStore("derby").initialize();
      }
    }

    if (config.getInitParameter("bdb-home") != null) {

      String myHome = config.getInitParameter("bdb-home");
      if (!myHome.startsWith("/")) {
        myHome = path + File.separator + myHome;
      }

      log.info("bdb-home(final)=" + myHome);
      System.setProperty("xpsq.bdb.home", myHome);

      if (PsqContext.getStore("bdb") != null) {
        PsqContext.getStore("bdb").initialize();
      }
    }
  }
Esempio n. 11
0
  static {
    System.setProperty("svnkit.log.native.calls", "true");
    final JavaSVNDebugLogger logger =
        new JavaSVNDebugLogger(
            Boolean.getBoolean(LOG_PARAMETER_NAME), Boolean.getBoolean(TRACE_NATIVE_CALLS), LOG);
    SVNDebugLog.setDefaultLog(logger);

    SVNJNAUtil.setJNAEnabled(true);
    SvnHttpAuthMethodsDefaultChecker.check();

    SVNAdminAreaFactory.setSelector(new SvnFormatSelector());

    DAVRepositoryFactory.setup();
    SVNRepositoryFactoryImpl.setup();
    FSRepositoryFactory.setup();

    // non-optimized writing is fast enough on Linux/MacOS, and somewhat more reliable
    if (SystemInfo.isWindows) {
      SVNAdminArea14.setOptimizedWritingEnabled(true);
    }

    if (!SVNJNAUtil.isJNAPresent()) {
      LOG.warn("JNA is not found by svnkit library");
    }
    initLogFilters();

    ourSSLProtocolsExplicitlySet = System.getProperty(SVNKIT_HTTP_SSL_PROTOCOLS) != null;
  }
Esempio n. 12
0
  /**
   * Sets the 'java.rmi.server.hostname' system property. <br>
   * WARNING: Call it before creating rmi registry else it is of no use. </br>
   */
  private void setRmiRegistryIpAddress() {

    StringBuilder bf = new StringBuilder();
    try {
      NetworkInterface iface;
      for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
          ifaces.hasMoreElements(); ) {
        iface = (NetworkInterface) ifaces.nextElement();
        InetAddress ia;
        Enumeration ips = iface.getInetAddresses();
        while (ips.hasMoreElements()) {
          ia = (InetAddress) ips.nextElement();
          // get all the ip aliases from all the network cards except for
          // loopback addresses. loop back addresses are not included because, then rmi registry
          // would
          // export objects on 127.0.0.1 or localhost => hence server would be accessible to clients
          // present only on localhost i.e the same machine as server!!!!
          if (ia instanceof Inet4Address && !ia.isLoopbackAddress()) {
            String ip = ia.getHostAddress();
            bf.append(ip);
            bf.append(',');
          }
        }
      }
      String hosts = bf.toString();
      if (hosts.endsWith(",")) // hosts="a,b,c,"
      hosts = hosts.substring(0, hosts.lastIndexOf(",")); // hosts="a,b,c"
      // Note: if network card is disabled=>hosts is empty, rmi runtimes uses localhost/127.0.0.1.
      System.setProperty("java.rmi.server.hostname", hosts);
    } catch (SocketException e) {
      e.printStackTrace();
    }
  }
 private static void patchSystemFileEncoding(String encoding)
     throws NoSuchFieldException, IllegalAccessException {
   Field charset = Charset.class.getDeclaredField("defaultCharset");
   charset.setAccessible(true);
   charset.set(Charset.class, null);
   System.setProperty("file.encoding", encoding);
 }
Esempio n. 14
0
  public static void main(String[] args) {

    Properties prop = System.getProperties();

    // 因为Properties是Hashtable的子类,也就是Map集合的一个子类对象。
    // 那么可以通过map的方法取出该集合中的元素。
    // 该集合中存储的都是字符串。没有泛型定义。

    // 如何在系统中自定义一些系统信息

    System.setProperty("mykey", "myvalue");

    // 获取指定属性信息

    String osvalue = System.getProperty("os.name");

    System.out.println("value=" + osvalue);

    // 可不可以在JVM启动时,动态地加载一些属性信息
    // -D<name>=<value>  设置系统属性

    // 获取所有属性信息

    for (Object obj : prop.keySet()) {
      String value = (String) prop.get(obj);

      System.out.println(obj + "::" + value);
    }
  }
Esempio n. 15
0
 @Override
 public void setUp() throws Exception {
   super.setUp();
   defaultFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
   System.setProperty(
       Context.INITIAL_CONTEXT_FACTORY, "org.crsh.shell.factory.JPAInitialContextFactory");
 }
Esempio n. 16
0
 public static String getNSSLibDir() throws Exception {
   Properties props = System.getProperties();
   String osName = props.getProperty("os.name");
   if (osName.startsWith("Win")) {
     osName = "Windows";
     NSPR_PREFIX = "lib";
   }
   String osid =
       osName
           + "-"
           + props.getProperty("os.arch")
           + "-"
           + props.getProperty("sun.arch.data.model");
   String ostype = osMap.get(osid);
   if (ostype == null) {
     System.out.println("Unsupported OS, skipping: " + osid);
     return null;
     //          throw new Exception("Unsupported OS " + osid);
   }
   if (ostype.length() == 0) {
     System.out.println("NSS not supported on this platform, skipping test");
     return null;
   }
   String libdir = NSS_BASE + SEP + "lib" + SEP + ostype + SEP;
   System.setProperty("pkcs11test.nss.libdir", libdir);
   return libdir;
 }
Esempio n. 17
0
  public void setUp() throws Exception {
    super.setUp();
    theDaemon = getMockLockssDaemon();
    tempDir = getTempDir();
    String tempDirPath = tempDir.getAbsolutePath();
    System.setProperty("java.io.tmpdir", tempDirPath);

    Properties p = new Properties();
    p.setProperty(IdentityManager.PARAM_IDDB_DIR, tempDirPath + "iddb");
    p.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath);
    p.setProperty(IdentityManager.PARAM_LOCAL_IP, "127.0.0.1");
    p.setProperty(V3LcapMessage.PARAM_REPAIR_DATA_THRESHOLD, "4096");
    ConfigurationUtil.setCurrentConfigFromProps(p);
    IdentityManager idmgr = theDaemon.getIdentityManager();
    idmgr.startService();
    mPollMgr = new MockPollManager();
    theDaemon.setPollManager(mPollMgr);
    try {
      m_testID = idmgr.stringToPeerIdentity("127.0.0.1");
    } catch (IOException ex) {
      fail("can't open test host 127.0.0.1: " + ex);
    }
    m_repairProps = new CIProperties();
    m_repairProps.setProperty("key1", "val1");
    m_repairProps.setProperty("key2", "val2");
    m_repairProps.setProperty("key3", "val3");

    m_testVoteBlocks = V3TestUtils.makeVoteBlockList(10);
    m_testMsg = this.makeTestVoteMessage(m_testVoteBlocks);
  }
  private static void startJAASSNAA(
      String path,
      String urnprefix,
      String jaasModuleName,
      String jaasConfigFile,
      IUserAuthorization authorization) {

    log.debug(
        "Starting JAAS SNAA, path ["
            + path
            + "], prefix["
            + urnprefix
            + "], jaasConfigFile["
            + jaasConfigFile
            + "], jaasModuleName["
            + jaasModuleName
            + "], authorization["
            + authorization
            + "]");

    System.setProperty("java.security.auth.login.config", jaasConfigFile);

    JAASSNAA jaasSnaa = new JAASSNAA(urnprefix, jaasModuleName, authorization);

    HttpContext context = server.createContext(path);
    Endpoint endpoint = Endpoint.create(jaasSnaa);
    endpoint.publish(context);

    log.debug("Started JAAS SNAA on " + server.getAddress() + path);
  }
Esempio n. 19
0
  public LdapContext connect(String userName, String password) {

    // LdapContext ctxLdap = null;
    Hashtable<String, String> envDC = new Hashtable();

    keystore = secres.getString("KEYSTORE");
    System.setProperty("javax.net.ssl.trustStore", keystore);

    log.info("Connecting to ldap using principal=" + userName);

    envDC.put(Context.PROVIDER_URL, host);
    envDC.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    envDC.put(Context.SECURITY_AUTHENTICATION, "simple"); // simple
    envDC.put(Context.SECURITY_PRINCIPAL, userName); // "*****@*****.**"
    envDC.put(Context.SECURITY_CREDENTIALS, password);
    if (protocol != null && protocol.equalsIgnoreCase("SSL")) {
      envDC.put(Context.SECURITY_PROTOCOL, protocol);
    }

    try {
      return (new InitialLdapContext(envDC, null));
    } catch (NamingException ne) {
      log.info(ne.getMessage());
      return null;
    }
  }
  @Override
  public final void runBare() throws Throwable {
    // Patch a bug with maven that does not pass properly the system property
    // with an empty value
    if ("org.hsqldb.jdbcDriver".equals(System.getProperty("gatein.test.datasource.driver"))) {
      System.setProperty("gatein.test.datasource.password", "");
    }

    //
    log.info("Running unit test:" + getName());
    for (Map.Entry<?, ?> entry : System.getProperties().entrySet()) {
      if (entry.getKey() instanceof String) {
        String key = (String) entry.getKey();
        log.debug(key + "=" + entry.getValue());
      }
    }

    //
    beforeRunBare();

    //
    try {
      super.runBare();
      log.info("Unit test " + getName() + " completed");
    } catch (Throwable throwable) {
      log.error("Unit test " + getName() + " did not complete", throwable);

      //
      throw throwable;
    } finally {
      afterRunBare();
    }
  }
Esempio n. 21
0
 /** Constructs ... */
 public Dialback() {
   super();
   if (System.getProperty("s2s-ejabberd-bug-workaround-active") == null) {
     System.setProperty("s2s-ejabberd-bug-workaround-active", "true");
   }
   ejabberd_bug_workaround_active = Boolean.getBoolean("s2s-ejabberd-bug-workaround-active");
 }
  /**
   * @param args
   * @throws IOException
   */
  public static void main(String args[]) throws IOException {

    // Enable Debugging
    System.setProperty("DEBUG", "1");

    // Instantiate the Test Controller
    new TestDeviceManagerProtocol();

    // ********************************************
    // Prompt to enter a command
    // ********************************************

    System.out.println("Type exit to quit");
    System.out.print("SYSTEM>");

    BufferedReader keyboardInput;
    keyboardInput = new BufferedReader(new InputStreamReader(System.in));
    String command = "";

    try {
      while (!command.equalsIgnoreCase("exit")) {
        command = keyboardInput.readLine();
        if (!command.equalsIgnoreCase("exit")) {
          System.out.print("\nSYSTEM>");
        }
      }
    } finally {
      System.out.println("\nDisconnecting from ProtocolFactory");
      try {
        ProtocolFactory.shutdown();
      } catch (Exception e) {
      }
      ;
    }
  }
  public static void main(String[] args)
      throws ExecutionException, InterruptedException, InvocationTargetException,
          IllegalAccessException {
    for (String arg : args) {
      if (arg.startsWith("fan=")) System.setProperty("cassandra.btree.fanfactor", arg.substring(4));
      else if (arg.startsWith("min=")) minTreeSize = Integer.parseInt(arg.substring(4));
      else if (arg.startsWith("max=")) maxTreeSize = Integer.parseInt(arg.substring(4));
      else if (arg.startsWith("count=")) perThreadTrees = Integer.parseInt(arg.substring(6));
      else exit();
    }

    List<Method> methods = new ArrayList<>();
    for (Method m : LongBTreeTest.class.getDeclaredMethods()) {
      if (m.getParameters().length > 0) continue;
      for (Annotation annotation : m.getAnnotations())
        if (annotation.annotationType() == Test.class) methods.add(m);
    }

    LongBTreeTest test = new LongBTreeTest();
    Collections.sort(methods, (a, b) -> a.getName().compareTo(b.getName()));
    log(Lists.transform(methods, (m) -> m.getName()).toString());
    for (Method m : methods) {
      log(m.getName());
      m.invoke(test);
    }
    log("success");
  }
Esempio n. 24
0
  /**
   * @param args arg[0] - URL of the Virtual Center Server / ESX host https://<Server host name /
   *     ip>/sdk arg[1] - User name arg[2] - Password arg[3] - One of vminfo, hostvminfo, or vmmor
   *     arg[4] - If vmmor is arg[3], then vmname argument is mandatory
   */
  public static void main(String[] args) {
    // This is to accept all SSL certifcates by default.
    System.setProperty(
        "org.apache.axis.components.net.SecureSocketFactory",
        "org.apache.axis.components.net.SunFakeTrustSocketFactory");
    if (args.length < 3) {
      printUsage();
    } else {
      try {
        /**
         * ****************************** ******************************* ** *** ** Your code goes
         * here *** ** (fill-in 1 of 1) *** ** *** *******************************
         * *******************************
         */
        VIM_HOST = args[0];
        USER_NAME = args[1];
        PASSWORD = args[2];
        initAll();
        System.out.println("***************************************************************");

        long st = System.currentTimeMillis();
        getVMInfo();
        long et = System.currentTimeMillis();
        System.out.println(
            "\nTotal time (msec) to retrieve the properties of all VMs in one call: " + (et - st));
        System.out.println("\n***************************************************************");
        System.out.println("\n***************************************************************");
        st = System.currentTimeMillis();
        initVMMorList();
        Iterator<ManagedObjectReference> iter = VM_MOR_LIST.iterator();
        StringBuilder sb = new StringBuilder();
        String name = "name";
        String powerState = "runtime.powerState";
        while (iter.hasNext()) {
          ManagedObjectReference vmMor = iter.next();
          String vmName = (String) getVMProperty(vmMor, name);
          sb.append(vmName);
          VirtualMachinePowerState vmPs =
              (VirtualMachinePowerState) getVMProperty(vmMor, powerState);
          sb.append(" : ");
          sb.append(vmPs);
          sb.append("\n");
        }
        et = System.currentTimeMillis();
        System.out.println(sb.toString());
        System.out.println(
            "\nTotal time (msec) to retrieve the properties of all VMs individually: " + (et - st));
        System.out.println("\n***************************************************************");
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        try {
          disconnect();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
Esempio n. 25
0
 private static void processSystemArguments(CommandLine allArgs) {
   Properties systemProps = allArgs.getSystemProperties();
   if (systemProps != null) {
     for (Map.Entry<Object, Object> entry : systemProps.entrySet()) {
       System.setProperty(entry.getKey().toString(), entry.getValue().toString());
     }
   }
 }
  @SuppressWarnings("unchecked")
  public void dumpCoverageAndConceptVectorAll(
      String fileEntityMI, String fileEntityEntropy, String fileEntityFreq, String fileCoverage) {
    BufferedWriter bwFileCoverage;

    HashMap<String, Double> entityMIMap = new GetEntityMI().getEntityMI(fileEntityMI);

    HashMap<String, Double> entityEntropyMap = new GetEntityMI().getEntityMI(fileEntityEntropy);

    HashMap<String, Double> entityFreqMap = new GetEntityFreq().getEntityFreq(fileEntityFreq);
    if (entityMIMap == null) {
      try {
        bwFileCoverage = new BufferedWriter(new FileWriter(fileCoverage));
        bwFileCoverage.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
      return;
    }

    conceptCoverageMap = new HashMap<>();
    Vector<Integer> conceptList = new Vector<>();

    try {
      for (Integer id : ProbaseData.conceptEntitySetMap.keySet()) {
        double coverage =
            getConceptCoverage(
                ProbaseData.idTermMap.get(id), entityMIMap, entityEntropyMap, entityFreqMap);
        if (coverage != 0) {
          conceptCoverageMap.put(id, coverage);
          conceptList.add(id);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
    Collections.sort(conceptList, new cmp());
    try {
      bwFileCoverage = new BufferedWriter(new FileWriter(fileCoverage));

      for (Integer id : conceptList) {
        bwFileCoverage.write(
            String.valueOf(id)
                + "\t"
                + ProbaseData.idTermMap.get(id)
                + "\t"
                + String.valueOf(conceptCoverageMap.get(id)));
        bwFileCoverage.newLine();
        bwFileCoverage.flush();
      }
      bwFileCoverage.flush();
      bwFileCoverage.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 27
0
 @Override
 protected void tearDown() throws Exception {
   super.tearDown();
   if (defaultFactory == null) {
     System.clearProperty(Context.INITIAL_CONTEXT_FACTORY);
   } else {
     System.setProperty(Context.INITIAL_CONTEXT_FACTORY, defaultFactory);
   }
 }
Esempio n. 28
0
  public ParseEssay() {
    System.setProperty("wordnet.database.dir", "../war/dict");
    synonyms = new ArrayList<String>();
    database = WordNetDatabase.getFileInstance();
    baos = new ByteArrayOutputStream();
    lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");

    // ??
  }
  public static void main(String[] args) throws Exception {

    long timeBeforeInMillis = System.currentTimeMillis();

    JmxInvokerArguments arguments = new JmxInvokerArguments();
    CmdLineParser parser = new CmdLineParser(arguments);
    try {
      parser.parseArgument(args);
      arguments.cmdLineParser = parser;
      if (Strings2.isEmpty(arguments.pid) && arguments.pidFile == null) {
        throw new CmdLineException(parser, "Options --pid and --pid-file can NOT be both null");
      } else if (!Strings2.isEmpty(arguments.pid) && arguments.pidFile != null) {
        throw new CmdLineException(parser, "Options --pid and --pid-file can NOT be both defined");
      } else if ((arguments.attribute == null || arguments.attribute.length == 0)
          && (arguments.operation == null || arguments.operation.length == 0)
          && arguments.listMbeans == false
          && arguments.describeMbeans == false) {
        throw new CmdLineException(
            parser,
            "Option --attribute or --operation or --list-mbeans or --describe-mbeans must be defined");
      } else if ((arguments.attribute != null && arguments.attribute.length > 0)
          && (arguments.operation != null && arguments.operation.length > 0)) {
        throw new CmdLineException(
            parser, "Options --attribute and --operation can NOT be both defined");
      }

      String logLevel;
      if (arguments.superVerbose) {
        logLevel = "TRACE";
      } else if (arguments.verbose) {
        logLevel = "DEBUG";
      } else {
        logLevel = "WARN";
      }
      System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, logLevel);

      Map<ObjectName, Result> results = new JmxInvoker().process(arguments);
      for (Map.Entry<ObjectName, Result> entry : results.entrySet()) {
        System.out.println(entry.getValue().description);
      }
    } catch (CmdLineException e) {
      System.err.println("INVALID INVOCATION: " + e.getMessage());
      System.err.println("Arguments: " + Strings2.join(args, " "));
      System.err.println("Usage:");
      parser.printUsage(System.err);
      throw e;
    } catch (Exception e) {
      System.err.println("INVALID INVOCATION: " + e.getMessage());
      System.err.println("Arguments: " + Strings2.join(args, " "));
      e.printStackTrace();
      throw e;
    } finally {
      if (arguments.verbose || arguments.superVerbose) {
        System.out.println("Duration: " + (System.currentTimeMillis() - timeBeforeInMillis) + "ms");
      }
    }
  }
Esempio n. 30
0
  public int executeScriptWithCaching(CommandLine commandLine) {
    processSystemArguments(commandLine);

    System.setProperty("grails.cli.args", commandLine.getRemainingArgsLineSeparated());
    return executeScriptWithCaching(
        commandLine,
        GrailsNameUtils.getNameFromScript(commandLine.getCommandName()),
        commandLine.getEnvironment());
  }