Search in sources :

Example 1 with MultiKeyMap

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);
}
Also used : MultiKeyMap(org.apache.commons.collections.map.MultiKeyMap) ArrayList(java.util.ArrayList) Collection(java.util.Collection) DataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo)

Example 2 with MultiKeyMap

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();
}
Also used : INode(org.talend.core.model.process.INode) MultiKeyMap(org.apache.commons.collections.map.MultiKeyMap) AbstractNode(org.talend.core.model.process.AbstractNode) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) AbstractNode(org.talend.core.model.process.AbstractNode) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Process(org.talend.designer.core.ui.editor.process.Process) IConnection(org.talend.core.model.process.IConnection) INodeConnector(org.talend.core.model.process.INodeConnector) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)2 MultiKeyMap (org.apache.commons.collections.map.MultiKeyMap)2 DataSourceBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo)1 DataSourceListBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo)1 Collection (java.util.Collection)1 List (java.util.List)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 AbstractNode (org.talend.core.model.process.AbstractNode)1 IConnection (org.talend.core.model.process.IConnection)1 INode (org.talend.core.model.process.INode)1 INodeConnector (org.talend.core.model.process.INodeConnector)1 Connection (org.talend.designer.core.ui.editor.connections.Connection)1 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1 Process (org.talend.designer.core.ui.editor.process.Process)1