@Test (expected=NetworkAllocationException.class) public void shouldLimitNumberOfNetworks() { for (int i = 0 ; i <= NUMBER_OF_NETWORKS ; i++) { node.getNetworkForKey(new NetworkKey(i,0,0,0,0,0,0,0)); } }
public synchronized Network getNetworkForKey(NetworkKey key) { int count = 0; Integer freeIndex = null; for (Network network : networks) { NetworkKey currentNetworkKey = network.getNetworkKey(); if (currentNetworkKey == null) { if (freeIndex == null) { freeIndex = count; } } else if (currentNetworkKey.equals(key)) { return new NetworkHandle(network); } count++; } if (freeIndex == null) { throw new NetworkAllocationException("No free networks available"); } setNetworkKey(freeIndex, key, true); return new NetworkHandle(networks[freeIndex]); }
Node { public synchronized Network getNetworkForKey(NetworkKey key) { int count = 0; Integer freeIndex = null; for (Network network : networks) { NetworkKey currentNetworkKey = network.getNetworkKey(); if (currentNetworkKey == null) { if (freeIndex == null) { freeIndex = count; } } else if (currentNetworkKey.equals(key)) { return new NetworkHandle(network); } count++; } if (freeIndex == null) { throw new NetworkAllocationException("No free networks available"); } setNetworkKey(freeIndex, key, true); return new NetworkHandle(networks[freeIndex]); } }
Node { public synchronized Network getNetworkForKey(NetworkKey key) { int count = 0; Integer freeIndex = null; for (Network network : networks) { NetworkKey currentNetworkKey = network.getNetworkKey(); if (currentNetworkKey == null) { if (freeIndex == null) { freeIndex = count; } } else if (currentNetworkKey.equals(key)) { return new NetworkHandle(network); } count++; } if (freeIndex == null) { throw new NetworkAllocationException("No free networks available"); } setNetworkKey(freeIndex, key, true); return new NetworkHandle(networks[freeIndex]); } Node(AntChipInterface antchip); }
Node { public synchronized Network getNetworkForKey(NetworkKey key) { int count = 0; Integer freeIndex = null; for (Network network : networks) { NetworkKey currentNetworkKey = network.getNetworkKey(); if (currentNetworkKey == null) { if (freeIndex == null) { freeIndex = count; } } else if (currentNetworkKey.equals(key)) { return new NetworkHandle(network); } count++; } if (freeIndex == null) { throw new NetworkAllocationException("No free networks available"); } setNetworkKey(freeIndex, key, true); return new NetworkHandle(networks[freeIndex]); } Node(AntChipInterface antchip); AntChipInterface getAntChip(); synchronized void registerStatusListener(
			BroadcastListener<AntStatusUpdate> listener); synchronized void removeStatusListener(
			BroadcastListener<AntStatusUpdate> listener); synchronized List<Capability> getCapabiltites(); synchronized void start(); synchronized Channel getFreeChannel(); synchronized void freeChannel(Channel channel); @Deprecated synchronized void setNetworkKey(int network, NetworkKey key); synchronized Network getNetworkForKey(NetworkKey key); synchronized int getMaxNetworks(); synchronized int getMaxChannels(); StandardMessage sendAndWaitWithAdapter(WaitAdapter waitAdapter,
			StandardMessage msg, LockExchangeContainer lockContainer); StandardMessage sendAndWaitWithAdapter(WaitAdapter waitAdapter,
			StandardMessage msg, LockExchangeContainer lockContainer,
			MessageSender sender, Receipt receipt); synchronized void registerRxListener(
			final BroadcastListener<V> listener, final Class<V> clazz); synchronized void removeRxListener(
			final BroadcastListener<V> listener); StandardMessage sendAndWaitForMessage(final StandardMessage msg,
			final MessageCondition condition, final Long timeout,
			final TimeUnit timeoutUnit, final MessageSender sender,
			final Receipt receipt); StandardMessage sendAndWaitForMessage(final StandardMessage msg,
			final MessageCondition condition, final Long timeout,
			final TimeUnit timeoutUnit, final MessageSender sender,
			final Receipt receipt, final MessageCondition errorCheckCondition); synchronized void reset(boolean wait); void reset(); synchronized MessageMetaWrapper<StandardMessage> send(
			StandardMessage msg); synchronized void stop(); synchronized boolean isRunning(); void registerAntLogger(AntLogger logger); void unregisterAntLogger(AntLogger logger); void registerEventHandler(NodeEventHandler handler); void sendAndWaitForResponseNoError(StandardMessage msg); synchronized void setTransmitPower(int powerLevel); synchronized void setLibConfig(boolean enableChannelId, boolean enableRssi,
			boolean enableTimestamps); synchronized void enableExtendedMessages(boolean enable); }
Node { public synchronized Network getNetworkForKey(NetworkKey key) { int count = 0; Integer freeIndex = null; for (Network network : networks) { NetworkKey currentNetworkKey = network.getNetworkKey(); if (currentNetworkKey == null) { if (freeIndex == null) { freeIndex = count; } } else if (currentNetworkKey.equals(key)) { return new NetworkHandle(network); } count++; } if (freeIndex == null) { throw new NetworkAllocationException("No free networks available"); } setNetworkKey(freeIndex, key, true); return new NetworkHandle(networks[freeIndex]); } Node(AntChipInterface antchip); AntChipInterface getAntChip(); synchronized void registerStatusListener(
			BroadcastListener<AntStatusUpdate> listener); synchronized void removeStatusListener(
			BroadcastListener<AntStatusUpdate> listener); synchronized List<Capability> getCapabiltites(); synchronized void start(); synchronized Channel getFreeChannel(); synchronized void freeChannel(Channel channel); @Deprecated synchronized void setNetworkKey(int network, NetworkKey key); synchronized Network getNetworkForKey(NetworkKey key); synchronized int getMaxNetworks(); synchronized int getMaxChannels(); StandardMessage sendAndWaitWithAdapter(WaitAdapter waitAdapter,
			StandardMessage msg, LockExchangeContainer lockContainer); StandardMessage sendAndWaitWithAdapter(WaitAdapter waitAdapter,
			StandardMessage msg, LockExchangeContainer lockContainer,
			MessageSender sender, Receipt receipt); synchronized void registerRxListener(
			final BroadcastListener<V> listener, final Class<V> clazz); synchronized void removeRxListener(
			final BroadcastListener<V> listener); StandardMessage sendAndWaitForMessage(final StandardMessage msg,
			final MessageCondition condition, final Long timeout,
			final TimeUnit timeoutUnit, final MessageSender sender,
			final Receipt receipt); StandardMessage sendAndWaitForMessage(final StandardMessage msg,
			final MessageCondition condition, final Long timeout,
			final TimeUnit timeoutUnit, final MessageSender sender,
			final Receipt receipt, final MessageCondition errorCheckCondition); synchronized void reset(boolean wait); void reset(); synchronized MessageMetaWrapper<StandardMessage> send(
			StandardMessage msg); synchronized void stop(); synchronized boolean isRunning(); void registerAntLogger(AntLogger logger); void unregisterAntLogger(AntLogger logger); void registerEventHandler(NodeEventHandler handler); void sendAndWaitForResponseNoError(StandardMessage msg); synchronized void setTransmitPower(int powerLevel); synchronized void setLibConfig(boolean enableChannelId, boolean enableRssi,
			boolean enableTimestamps); synchronized void enableExtendedMessages(boolean enable); final static Logger LOGGER; }