use of org.apache.commons.collections.map.MultiKeyMap in project pinpoint by naver.
the class HbaseDataSourceListDao method reorderDataSourceListBos.
private List<DataSourceListBo> reorderDataSourceListBos(List<DataSourceListBo> dataSourceListBos) {
// reorder dataSourceBo using id and timeSlot
MultiKeyMap dataSourceListBoMap = new MultiKeyMap();
for (DataSourceListBo dataSourceListBo : dataSourceListBos) {
for (DataSourceBo dataSourceBo : dataSourceListBo.getList()) {
int id = dataSourceBo.getId();
long timestamp = dataSourceBo.getTimestamp();
long timeSlot = AgentStatUtils.getBaseTimestamp(timestamp);
DataSourceListBo mappedDataSourceListBo = (DataSourceListBo) dataSourceListBoMap.get(id, timeSlot);
if (mappedDataSourceListBo == null) {
mappedDataSourceListBo = new DataSourceListBo();
mappedDataSourceListBo.setAgentId(dataSourceBo.getAgentId());
mappedDataSourceListBo.setStartTimestamp(dataSourceBo.getStartTimestamp());
mappedDataSourceListBo.setTimestamp(dataSourceBo.getTimestamp());
dataSourceListBoMap.put(id, timeSlot, mappedDataSourceListBo);
}
// set fastest timestamp
if (mappedDataSourceListBo.getTimestamp() > dataSourceBo.getTimestamp()) {
mappedDataSourceListBo.setTimestamp(dataSourceBo.getTimestamp());
}
mappedDataSourceListBo.add(dataSourceBo);
}
}
Collection values = dataSourceListBoMap.values();
return new ArrayList<DataSourceListBo>(values);
}
use of org.apache.commons.collections.map.MultiKeyMap in project tdi-studio-se by Talend.
the class DeleteNodeContainerCommand method execute.
@Override
@SuppressWarnings("unchecked")
public void execute() {
connectionDeletedInfosMap = new MultiKeyMap();
process.setActivate(false);
List uniqueNameList = new ArrayList();
for (INode node : nodeList) {
if (node.getJobletNode() != null) {
continue;
}
uniqueNameList.add(node.getUniqueName());
NodeContainer nodeContainer = ((Node) node).getNodeContainer();
((Process) process).removeNodeContainer(nodeContainer);
List<IConnection> inputList = (List<IConnection>) node.getIncomingConnections();
List<IConnection> outputList = (List<IConnection>) node.getOutgoingConnections();
boolean builtIn = node.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
for (IConnection connection : inputList) {
// see bug 0002633: "rejects" link disappears at times.
if (connection != null && connection.getSourceNodeConnector() != null) {
connection.getSourceNodeConnector().setCurLinkNbOutput(connection.getSourceNodeConnector().getCurLinkNbOutput() - 1);
}
INode prevNode = connection.getSource();
if ((prevNode instanceof Node) && ((Node) prevNode).getJobletNode() != null) {
Node jobletnode = (Node) prevNode.getJobletNode();
((AbstractJobletContainer) jobletnode.getNodeContainer()).getOutputs().remove(connection);
if (!nodeList.contains(jobletnode)) {
boolean builtInJobletNode = jobletnode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
storeMetadata(connection, jobletnode, true);
jobletnode.removeOutput(connection);
if (!builtInJobletNode) {
process.removeUniqueConnectionName(connection.getUniqueName());
}
}
}
if (!nodeList.contains(prevNode)) {
boolean builtInPrevNode = prevNode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
boolean remove = true;
if ((prevNode instanceof Node) && ((Node) prevNode).isELTMapComponent()) {
remove = false;
}
storeMetadata(connection, prevNode, remove);
prevNode.removeOutput(connection);
if (!builtInPrevNode && remove) {
process.removeUniqueConnectionName(connection.getUniqueName());
}
}
}
for (IConnection connection : outputList) {
INode nextNode = connection.getTarget();
if ((nextNode instanceof Node) && ((Node) nextNode).getJobletNode() != null) {
Node jobletnode = (Node) nextNode.getJobletNode();
((AbstractJobletContainer) jobletnode.getNodeContainer()).getInputs().remove(connection);
if (!nodeList.contains(jobletnode)) {
jobletnode.removeInput(connection);
boolean builtInJobletNode = jobletnode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
if (!builtInJobletNode) {
process.removeUniqueConnectionName(connection.getUniqueName());
}
}
}
if (!nodeList.contains(nextNode)) {
INodeConnector nodeConnector = nextNode.getConnectorFromType(connection.getLineStyle());
nodeConnector.setCurLinkNbInput(nodeConnector.getCurLinkNbInput() - 1);
nextNode.removeInput(connection);
if (nextNode != null) {
for (int i = 0; i < nextNode.getIncomingConnections().size(); i++) {
Connection nextNodeConnection = (Connection) nextNode.getIncomingConnections().get(i);
nextNodeConnection.updateName();
}
}
if (nextNode.getExternalNode() instanceof AbstractNode) {
((AbstractNode) nextNode.getExternalNode()).removeInput(connection);
}
}
if (!builtIn) {
process.removeUniqueConnectionName(connection.getUniqueName());
}
}
if (builtIn) {
for (IMetadataTable meta : node.getMetadataList()) {
String metaName = meta.getTableName();
process.removeUniqueConnectionName(metaName);
}
// for tmap remove join table names
final List<String> names = CorePlugin.getDefault().getMapperService().getJoinTableNames(node.getExternalData());
if (!names.isEmpty()) {
joinTableNames.addAll(names);
for (String name : joinTableNames) {
process.removeUniqueConnectionName(name);
}
}
}
}
process.setActivate(true);
process.checkStartNodes();
process.checkProcess();
}
Aggregations