Ejemplo n.º 1
0
 public static List<Integer> networkTagInterval() {
   final List<Integer> interval = Lists.newArrayList();
   for (Integer i = NetworkGroups.networkingConfiguration().getMinNetworkTag();
       i < NetworkGroups.networkingConfiguration().getMaxNetworkTag();
       i++) {
     interval.add(i);
   }
   return interval;
 }
Ejemplo n.º 2
0
 public static List<Long> networkIndexInterval() {
   final List<Long> interval = Lists.newArrayList();
   for (Long i = NetworkGroups.networkingConfiguration().getMinNetworkIndex();
       i < NetworkGroups.networkingConfiguration().getMaxNetworkIndex();
       i++) {
     interval.add(i);
   }
   return interval;
 }
Ejemplo n.º 3
0
 public ExtantNetwork extantNetwork()
     throws NotEnoughResourcesException, TransientEntityException {
   if (!NetworkGroups.networkingConfiguration().hasNetworking()) {
     ExtantNetwork bogusNet = ExtantNetwork.bogus(this);
     if (!this.hasExtantNetwork()) this.setExtantNetwork(bogusNet);
     return bogusNet;
   } else if (!Entities.isPersistent(this)) {
     throw new TransientEntityException(this.toString());
   } else {
     ExtantNetwork exNet = this.getExtantNetwork();
     if (exNet == null) {
       for (Integer i : Numbers.shuffled(NetworkGroups.networkTagInterval())) {
         try {
           Entities.uniqueResult(ExtantNetwork.named(i));
           continue;
         } catch (Exception ex) {
           exNet = ExtantNetwork.create(this, i);
           Entities.persist(exNet);
           this.setExtantNetwork(exNet);
           return this.getExtantNetwork();
         }
       }
       throw new NotEnoughResourcesException(
           "Failed to allocate network tag for network: "
               + this.getFullName()
               + ": no network tags are free.");
     } else {
       return this.getExtantNetwork();
     }
   }
 }
Ejemplo n.º 4
0
 public ExtantNetwork reclaim(Integer i)
     throws NotEnoughResourcesException, TransientEntityException {
   if (!NetworkGroups.networkingConfiguration().hasNetworking()) {
     return ExtantNetwork.bogus(this);
   } else if (!Entities.isPersistent(this)) {
     throw new TransientEntityException(this.toString());
   } else {
     ExtantNetwork exNet = Entities.persist(ExtantNetwork.create(this, i));
     this.setExtantNetwork(exNet);
     return this.getExtantNetwork();
   }
 }