NSAmelchev commented on a change in pull request #40: URL: https://github.com/apache/ignite-extensions/pull/40#discussion_r565212098
########## File path: modules/performance-statistics-ext/src/main/java/org/apache/ignite/internal/performancestatistics/handlers/PrintHandler.java ########## @@ -0,0 +1,256 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.performancestatistics.handlers; + +import java.io.PrintStream; +import java.util.BitSet; +import java.util.Set; +import java.util.UUID; +import com.fasterxml.jackson.databind.node.TextNode; +import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType; +import org.apache.ignite.internal.processors.performancestatistics.OperationType; +import org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsHandler; +import org.apache.ignite.internal.util.GridIntIterator; +import org.apache.ignite.internal.util.GridIntList; +import org.apache.ignite.lang.IgniteUuid; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_START; +import static org.apache.ignite.internal.processors.performancestatistics.OperationType.JOB; +import static org.apache.ignite.internal.processors.performancestatistics.OperationType.QUERY; +import static org.apache.ignite.internal.processors.performancestatistics.OperationType.QUERY_READS; +import static org.apache.ignite.internal.processors.performancestatistics.OperationType.TASK; +import static org.apache.ignite.internal.processors.performancestatistics.OperationType.TX_COMMIT; +import static org.apache.ignite.internal.processors.performancestatistics.OperationType.TX_ROLLBACK; + +/** + * Handler to print performance statistics operations. + */ +public class PrintHandler implements PerformanceStatisticsHandler { + /** Print stream. */ + private final PrintStream ps; + + /** Operation types. */ + @Nullable private final BitSet ops; + + /** Start time from. */ + private final long from; + + /** Start time to. */ + private final long to; + + /** Cache identifiers to filter the output. */ + @Nullable private final Set<Integer> cacheIds; + + /** + * @param ps Print stream. + * @param ops Set of operations to print. + * @param from The minimum operation start time to filter the output. + * @param to The maximum operation start time to filter the output. + * @param cacheIds Cache identifiers to filter the output. + */ + public PrintHandler(PrintStream ps, @Nullable BitSet ops, long from, long to, @Nullable Set<Integer> cacheIds) { + this.ps = ps; + this.ops = ops; + this.from = from; + this.to = to; + this.cacheIds = cacheIds; + } + + /** {@inheritDoc} */ + @Override public void cacheStart(UUID nodeId, int cacheId, String name) { + if (skip(CACHE_START, cacheId)) + return; + + ps.print("{\"op\":\"" + CACHE_START); + ps.print("\",\"nodeId\":\""); + ps.print(nodeId); + ps.print("\",\"cacheId\":"); + ps.print(cacheId); + ps.print(",\"name\":"); + ps.print(new TextNode(name)); Review comment: Done. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
