コード例 #1
0
ファイル: CybernodeUtils.java プロジェクト: dreedyman/Rio
 /**
  * Searches the specified array of Cybernodes for the first occurence
  * of a Cybernode running one or more service elements.
  *
  * @param cybernodes    the array to be searched
  * @return              the found Cybernode, if successful.
  *                      Otherwise <code>null</null>.
  *
  * @throws  RemoteException if there was a communication failure
  *          while attempting to access one of the Cybernodes from
  *          the specified array.
  */
 public static Cybernode findBusy(Cybernode[] cybernodes) throws RemoteException {
   for (Cybernode cybernode : cybernodes) {
     if (cybernode.getServiceStatements().length > 0) {
       return cybernode;
     }
   }
   return null;
 }
コード例 #2
0
ファイル: CybernodeUtils.java プロジェクト: dreedyman/Rio
 /**
  * Searches the specified list of Cybernodes for the first occurence
  * of a Cybernode running one or more service elements.
  *
  * @param cybernodes    the list to be searched
  * @return              the found Cybernode, if successful.
  *                      Otherwise <code>null</null>.
  */
 public static Cybernode findBusy(List<Cybernode> cybernodes) {
   for (Cybernode cybernode : cybernodes) {
     try {
       if (cybernode.getServiceStatements().length > 0) {
         return cybernode;
       }
     } catch (RemoteException e) {
       e.printStackTrace();
     }
   }
   return null;
 }
コード例 #3
0
ファイル: CybernodeUtils.java プロジェクト: dreedyman/Rio
  /**
   * Calculates the number of services of the specified type running on each of the specified
   * Cybernodes.
   *
   * @param cybernodes the Cybernodes to consider
   * @param type the service type to look for
   * @return the resulting array. Every element of this array stores the number of services of the
   *     specified type running on a specific Cybernode. The order of elements corresponds to the
   *     one of services in the <code>cybernodes</code> parameter.
   * @throws RemoteException if there was a communication failure while attempting to access one of
   *     the Cybernodes from the specified list.
   */
  public static int[] calcServices(Cybernode[] cybernodes, Class type) throws RemoteException {

    int[] res = new int[cybernodes.length];
    for (int i = 0; i < cybernodes.length; i++) {
      Cybernode cybernode = cybernodes[i];
      ServiceRecord[] records = cybernode.getServiceRecords(ServiceRecord.ACTIVE_SERVICE_RECORD);
      for (ServiceRecord record : records) {
        ServiceElement element = record.getServiceElement();
        ClassBundle[] exportBundles = element.getExportBundles();
        for (ClassBundle bundle : exportBundles) {
          if (bundle.getClassName().equals(type.getName())) {
            res[i]++;
            break;
          }
        }
      }
    }
    return res;
  }