Пример #1
0
 public void saveManager() throws FileNotFoundException, IOException {
   String workingDir = System.getProperty("user.dir");
   FileOutputStream fos = new FileOutputStream(workingDir + "\\Manager.ser");
   ObjectOutputStream oos = new ObjectOutputStream(fos);
   try {
     oos.writeObject(this);
     oos.close();
   } catch (IOException e) {
     System.out.println("\nerror saving file!\n");
   }
 }
Пример #2
0
 public Manager loadManager() throws IOException, ClassNotFoundException {
   try {
     String workingDir = System.getProperty("user.dir");
     FileInputStream fin = new FileInputStream(workingDir + "\\Manager.ser");
     ObjectInputStream oin = new ObjectInputStream(fin);
     Manager m = (Manager) oin.readObject();
     if (m != null) return m;
     else return new Manager(new Warehouse());
   } catch (IOException e) {
     System.out.println("\nerror loading file!\n");
     return new Manager(new Warehouse());
   }
 }
Пример #3
0
 @Override
 public void close() throws BlockStoreException {
   try {
     buffer.force();
     if (System.getProperty("os.name").toLowerCase().contains("win")) {
       log.info("Windows mmap hack: Forcing buffer cleaning");
       WindowsMMapHack.forceRelease(buffer);
     }
     buffer = null; // Allow it to be GCd and the underlying file mapping to go away.
     randomAccessFile.close();
   } catch (IOException e) {
     throw new BlockStoreException(e);
   }
 }
Пример #4
0
  private void generateCNAME() {
    String hostname;

    if (this.mcSession) {
      hostname = this.rtpMCSock.getLocalAddress().getCanonicalHostName();
    } else {
      hostname = this.rtpSock.getLocalAddress().getCanonicalHostName();
    }

    // if(hostname.equals("0.0.0.0") && System.getenv("HOSTNAME") != null) {
    //	hostname = System.getenv("HOSTNAME");
    // }

    cname = System.getProperty("user.name") + "@" + hostname;
  }
Пример #5
0
  static void realMain(String[] args) throws Throwable {
    // jmap doesn't work on Windows
    if (System.getProperty("os.name").startsWith("Windows")) return;

    final String childClassName = Job.class.getName();
    final String classToCheckForLeaks = Job.classToCheckForLeaks();
    final String uniqueID = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));

    final String[] jobCmd = {
      java,
      "-Xmx8m",
      "-classpath",
      System.getProperty("test.classes", "."),
      childClassName,
      uniqueID
    };
    final Process p = new ProcessBuilder(jobCmd).start();

    final String childPid =
        match(
            commandOutputOf(jps, "-m"),
            "(?m)^ *([0-9]+) +\\Q" + childClassName + "\\E *" + uniqueID + "$",
            1);

    final int n0 = objectsInUse(p, childPid, classToCheckForLeaks);
    final int n1 = objectsInUse(p, childPid, classToCheckForLeaks);
    equal(p.waitFor(), 0);
    equal(p.exitValue(), 0);
    failed += p.exitValue();

    // Check that no objects were leaked.
    System.out.printf("%d -> %d%n", n0, n1);
    check(Math.abs(n1 - n0) < 2); // Almost always n0 == n1
    check(n1 < 20);
    drainers.shutdown();
  }
Пример #6
0
 static String javahome() {
   String jh = System.getProperty("java.home");
   return (jh.endsWith("jre")) ? jh.substring(0, jh.length() - 4) : jh;
 }