public ChannelBuilder(Channel base) { if (base.getKey() == null) { this._key = new ChannelKey( base.getChannelId() ); this._channelId = base.getChannelId(); } else { this._key = base.getKey(); this._channelId = _key.getChannelId(); this._bytesIn = base.getBytesIn(); this._bytesOut = base.getBytesOut(); this._callHome = base.getCallHome(); this._channelAlarm = base.getChannelAlarm(); this._channelAlarms = base.getChannelAlarms(); this._channelType = base.getChannelType(); this._destination = base.getDestination(); this._session = base.getSession(); this._sessions = base.getSessions(); this._source = base.getSource(); if (base instanceof ChannelImpl) { ChannelImpl impl = (ChannelImpl) base;
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); }
/** * 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; }
List<ChannelAlarm> alarmList = channel.getChannelAlarm(); addAlarm(alarmList, alarm); channel = UscTopologyFactory.createChannel(getLocalController(), deviceNode, channel.getChannelId().getValue(), channel.getChannelType(), UscTopologyFactory.isCallHome(channel.getCallHome()), channel.getBytesIn(), channel.getBytesOut(), alarmList, channel.getSession()); updateChannel(channel);
/** * 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; }
/** * 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)); } } /**
/** * get session from the channel with specified session id * * @param channel * 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(Channel channel, String sessionId) { for (Session session : channel.getSession()) { if (session.getSessionId().getValue().equals(sessionId)) { return session; } } return null; }
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); }
/** * 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; }
/** * 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; }
if (!Objects.equals(_bytesIn, other.getBytesIn())) { return false; if (!Objects.equals(_bytesOut, other.getBytesOut())) { return false; if (!Objects.equals(_callHome, other.getCallHome())) { return false; if (!Objects.equals(_channelAlarm, other.getChannelAlarm())) { return false; if (!Objects.equals(_channelAlarms, other.getChannelAlarms())) { return false; if (!Objects.equals(_channelId, other.getChannelId())) { return false; if (!Objects.equals(_channelType, other.getChannelType())) { return false; if (!Objects.equals(_destination, other.getDestination())) { return false; if (!Objects.equals(_key, other.getKey())) { return false; if (!Objects.equals(_session, other.getSession())) { return false;