@Override
 public PeerItem onLocalInstance(int localPort) {
   /*
    * store information
    */
   PeerItem item = new PeerItem();
   item.networkName = NETWORK;
   item.isMaster = true;
   item.distributionStrategy = DISTRIBUTION.toString();
   item.port = localPort;
   item.useSubgraphSubmission = withSubgraphSubmission;
   /*
    * store configuration
    */
   Map<String, Object> cfg =
       P2P_QueryClient_Instanciator.getP2PImplementationConfiguration();
   cfg.put(P2PNetworkCreator.P2PConfigurationConstants.cPORT, localPort);
   cfg.remove(P2PNetworkCreator.P2PConfigurationConstants.cMASTER_IP);
   cfg.remove(P2PNetworkCreator.P2PConfigurationConstants.cMASTER_PORT);
   P2P_QueryClient_Instanciator.setP2PImplementationConfiguration(cfg);
   P2P_QueryClient_Instanciator.setSubgraphSubmission(withSubgraphSubmission);
   // create instance and store instance
   QueryClient qC = createInstance();
   item.queryEvaluator = qC;
   return item;
 }
        @Override
        public PeerItem onMasterInstance(int localPort, int masterPort, String masterAddress) {
          // store information
          PeerItem item = new PeerItem();
          item.networkName = NETWORK;
          item.isMaster = false;
          item.masterName = masterAddress;
          item.masterPort = masterPort;
          item.distributionStrategy = DISTRIBUTION.toString();
          item.port = localPort;
          item.useSubgraphSubmission = withSubgraphSubmission;

          // set ports and master
          Map<String, Object> cfg =
              P2P_QueryClient_Instanciator.getP2PImplementationConfiguration();
          cfg.put(P2PNetworkCreator.P2PConfigurationConstants.cPORT, localPort);
          cfg.put(P2PNetworkCreator.P2PConfigurationConstants.cMASTER_IP, masterAddress);
          cfg.put(P2PNetworkCreator.P2PConfigurationConstants.cMASTER_PORT, masterPort);
          P2P_QueryClient_Instanciator.setP2PImplementationConfiguration(cfg);
          P2P_QueryClient_Instanciator.setSubgraphSubmission(withSubgraphSubmission);
          // create instance and store instance
          QueryClient qC = createInstance();
          item.queryEvaluator = qC;
          return item;
        }
  /**
   * Returns an already running queryClient or starts a new one
   *
   * @return a new evaluator which can be used in LuposDate UI
   */
  public QueryClient newInstance() {
    try {
      P2P_QueryClient_Instanciator.lock();
      P2P_QueryClient_Instanciator.setP2PImplementationConstant(NETWORK);
      /*should be configured before via UI? */
      P2P_QueryClient_Instanciator.setP2PDistributionStrategy(DISTRIBUTION);
      P2P_QueryClient_Instanciator.setSubgraphSubmission(withSubgraphSubmission);

      /*
       * ask which instance is to be used
       */
      PeerItem instance = configurationUI.showDialog();
      if (instance != null && instance.queryEvaluator != null) return instance.queryEvaluator;
      return null;
    } finally {
      P2P_QueryClient_Instanciator.unlock();
    }
  }
 private QueryClient createInstance() {
   return P2P_QueryClient_Instanciator.newInstance();
 }