コード例 #1
0
ファイル: Recorder.java プロジェクト: markus1978/clickwatch
 private final void save() {
   if (saveRecordFile) {
     Resource resource = record.eResource();
     if (resource != null) {
       try {
         resource.save(EmfXmlUtil.defaultLoadSaveOptions());
       } catch (IOException e) {
         Throwables.propagate(e);
       }
     }
   }
 }
コード例 #2
0
  public void record(String[] args) {
    String recordFile = args[0];
    ResourceSet rs = new ResourceSetImpl();
    Resource resource = rs.createResource(URI.createFileURI(recordFile));

    Map<Object, Object> options = new HashMap<Object, Object>();
    options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

    for (int record = 0; record < NUMBER_OF_RECORDS; record++) {
      System.out.println("start to retrieve data in round " + record);
      Network result = ClickWatchModelFactory.eINSTANCE.createNetwork();
      RetrieveLoop:
      for (int i = 1; i < args.length; i++) {
        String host = args[i];
        String port = "7777";

        Node node = null;
        try {
          node = retrieve(host, port);
          node.setPort(port);
          node.setINetAddress(host);
        } catch (Throwable e) {
          e.printStackTrace();
          System.err.println("Exception while retrieving " + host + "[" + port + "]\n");
          continue RetrieveLoop;
        }
        result.getNodes().add(node);
        System.out.println("successfully retrieved one set of data from " + host);
      }
      resource.getContents().add(result);

      try {
        Thread.sleep(UPDATE_INTERVALL);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }

    try {
      resource.save(options);
    } catch (IOException e) {
      e.printStackTrace();
      Throwables.propagate(e);
    }
  }