/** * get first channel of specified destination id * * @param destinationId * destination node id * @return the channel, if the channel related with specified destination id * is not exists then return null */ public synchronized Channel getChannel(String destinationId, String type) { for (Channel channel : localTopology.getChannel()) { if (channel.getDestination().getDestNode().getValue().equals(destinationId) && channel.getChannelType().equals(type)) { return channel; } } return null; }
/** * add a channel to topology channel list without update shard * * @param channel * the adding channel */ public synchronized void addChannelWithoutUpdateShard(Channel channel) { if (channel != null) { localTopology.getChannel().add(channel); addNode(UscTopologyFactory.createNode(channel.getDestination().getDestNode().getValue(), UscTopologyService.NODE_TYPE_NETWORK_DEVICE)); } } /**
/** * remove the channel specified by the destination id,and same time will * remove the corresponding source and destination nodes without update Shard * * @param destinationId * node id of the destination node * @param type * the type of channel * @return the channel of the removing channel,if the channel related with * specified destination id is not exists then return null */ public synchronized Channel removeChannelWithoutUpdateShard(String destinationId, String type) { if (destinationId != null) { Channel channel = getChannel(destinationId, type); if (channel != null) { localTopology.getChannel().remove(channel); // source controller node only add once on initializing // removeNode(channel.getSource().getSourceNode().getValue()); removeNode(channel.getDestination().getDestNode().getValue()); return channel; } else { LOG.warn("Not found specified destionation.id =" + destinationId); } } return null; }
return false; if (!Objects.equals(_destination, other.getDestination())) { return false;
/** * get session which has specified session id from the channel which has the * destination id * * @param destinationId * the target channel for getting * @param sessionId * specified session id * @return if find the session which has the session id, return the session * other wise return null */ public synchronized Session getSession(String destinationId, String sessionId, String type) { for (Channel channel : localTopology.getChannel()) { if (channel.getDestination().getDestNode().getValue().equals(destinationId) && channel.getChannelType().equals(type)) { for (Session session : channel.getSession()) { if (session.getSessionId().getValue().equals(sessionId)) { return session; } } } } return null; }
this._channelAlarms = base.getChannelAlarms(); this._channelType = base.getChannelType(); this._destination = base.getDestination(); this._session = base.getSession(); this._sessions = base.getSessions();
/** * update channel information, and update the shard data of local topology * * @param channel * the new channel * @return old channel */ public synchronized Channel updateChannel(Channel channel) { if (channel != null) { Channel oldChannel = removeChannelWithoutUpdateShard(channel.getDestination().getDestNode().getValue(), channel.getChannelType()); addChannelWithoutUpdateShard(channel); updateShard(); return oldChannel; } return null; }
public synchronized void updateTransaction(Channel channel, Session session, long bytesIn, long bytesOut) { Session oldSession = getSession(channel, session.getSessionId().getValue()); if (oldSession != null) { channel.getSession().remove(oldSession); } channel.getSession().add(session); String destinationId = channel.getDestination().getDestNode().getValue(); Node deviceNode = UscTopologyFactory.createNode(destinationId, UscTopologyService.NODE_TYPE_NETWORK_DEVICE); channel = UscTopologyFactory.createChannel(getLocalController(), deviceNode, channel.getKey().getChannelId() .getValue(), channel.getChannelType(), UscTopologyFactory.isCallHome(channel.getCallHome()), channel.getBytesIn() + bytesIn, channel.getBytesOut() + bytesOut, channel.getChannelAlarm(), channel.getSession()); updateChannel(channel); }
public synchronized void updateChannel(Channel channel, Session session, boolean removeFlag) { Session oldSession = getSession(channel, session.getSessionId().getValue()); if (oldSession != null) { channel.getSession().remove(oldSession); } if (!removeFlag) { channel.getSession().add(session); } String destinationId = channel.getDestination().getDestNode().getValue(); Node deviceNode = UscTopologyFactory.createNode(destinationId, UscTopologyService.NODE_TYPE_NETWORK_DEVICE); channel = UscTopologyFactory.createChannel(getLocalController(), deviceNode, channel.getKey().getChannelId() .getValue(), channel.getChannelType(), UscTopologyFactory.isCallHome(channel.getCallHome()), channel.getBytesIn(), channel.getBytesOut(), channel.getChannelAlarm(), channel.getSession()); updateChannel(channel); }