X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fservice%2FQueryControl.java;h=5cc3fa65589cadbd71ade1236e4db2899cf8e28c;hb=c26409b1caf2f1e560d37c5befd11b442399c3fe;hp=2eaa144040b1e69fcfe6f41da4e8a8ab4a1b3291;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db/src/org/simantics/db/service/QueryControl.java b/bundles/org.simantics.db/src/org/simantics/db/service/QueryControl.java index 2eaa14404..5cc3fa655 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/service/QueryControl.java +++ b/bundles/org.simantics.db/src/org/simantics/db/service/QueryControl.java @@ -1,98 +1,98 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.db.service; - -import java.util.Collection; - -import org.simantics.db.AsyncReadGraph; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.procedure.AsyncContextMultiProcedure; -import org.simantics.db.procedure.AsyncMultiProcedure; -import org.simantics.db.request.ExternalRead; - - -/** - * @author Antti Villberg - */ -public interface QueryControl { - - interface ControlProcedure { - void execute(AsyncReadGraph graph); - } - - /** - * - * @return current amount of queries - */ - int count(); - - /** - * @return The amount of fixed queries after best effort flush - */ - int flush(); - int flush(ReadGraph graph); - - /** - * - * @param allowedTimeInMs The amount of allowed time use in ms. - */ - void gc(ReadGraph graph, int allowedTimeInMs); - - /** - * Collects all external read requests and their parent queries that are no - * longer listened to. Needs to perform exclusive locking of the database - * client internally so do not invoke this from within a graph read or write - * request but use {@link #gc(WriteGraph, Collection)} instead. - * - * @param reads - */ - void gc(Collection> reads); - - /** - * Collects all external read requests and their parent queries that are no - * longer listened to. The write graph argument is used to ensure that the - * invocation is performed from within a write request with exclusive - * locking. - * - * @param graph write request handle - * @param reads the external read requests to attempt garbage collection for - */ - void gc(WriteGraph graph, Collection> reads); - - int getAmountOfQueryThreads(); - - int getGraphThread(AsyncReadGraph graph); - - boolean resume(AsyncReadGraph graph); - - void schedule(AsyncReadGraph graph, int targetThread, ControlProcedure procedure); - - boolean scheduleByCluster(AsyncReadGraph graph, Resource resource, AsyncMultiProcedure procedure); - boolean scheduleByCluster(AsyncReadGraph graph, Resource resource, C context, AsyncContextMultiProcedure procedure); - - /** - * Returns a new ReadGraph based on the specified ReadGraph. The returned - * ReadGraph does not accumulate query dependencies into the requests - * performed with the specified ReadGraph. DB listeners are therefore not - * triggered by anything that is performed with the returned ReadGraph. - * - * @param graph read transaction handle to clone for listener-independent - * use - * @return read transaction handle that is independent of the requests - * performed with the parameter - */ - ReadGraph getIndependentGraph(ReadGraph graph); - boolean hasParentRequest(ReadGraph graph); - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.db.service; + +import java.util.Collection; + +import org.simantics.db.AsyncReadGraph; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.procedure.AsyncContextMultiProcedure; +import org.simantics.db.procedure.AsyncMultiProcedure; +import org.simantics.db.request.ExternalRead; + + +/** + * @author Antti Villberg + */ +public interface QueryControl { + + interface ControlProcedure { + void execute(AsyncReadGraph graph); + } + + /** + * + * @return current amount of queries + */ + int count(); + + /** + * @return The amount of fixed queries after best effort flush + */ + int flush(); + int flush(ReadGraph graph); + + /** + * + * @param allowedTimeInMs The amount of allowed time use in ms. + */ + void gc(ReadGraph graph, int allowedTimeInMs); + + /** + * Collects all external read requests and their parent queries that are no + * longer listened to. Needs to perform exclusive locking of the database + * client internally so do not invoke this from within a graph read or write + * request but use {@link #gc(WriteGraph, Collection)} instead. + * + * @param reads + */ + void gc(Collection> reads); + + /** + * Collects all external read requests and their parent queries that are no + * longer listened to. The write graph argument is used to ensure that the + * invocation is performed from within a write request with exclusive + * locking. + * + * @param graph write request handle + * @param reads the external read requests to attempt garbage collection for + */ + void gc(WriteGraph graph, Collection> reads); + + int getAmountOfQueryThreads(); + + int getGraphThread(AsyncReadGraph graph); + + boolean resume(AsyncReadGraph graph); + + void schedule(AsyncReadGraph graph, int targetThread, ControlProcedure procedure); + + boolean scheduleByCluster(AsyncReadGraph graph, Resource resource, AsyncMultiProcedure procedure); + boolean scheduleByCluster(AsyncReadGraph graph, Resource resource, C context, AsyncContextMultiProcedure procedure); + + /** + * Returns a new ReadGraph based on the specified ReadGraph. The returned + * ReadGraph does not accumulate query dependencies into the requests + * performed with the specified ReadGraph. DB listeners are therefore not + * triggered by anything that is performed with the returned ReadGraph. + * + * @param graph read transaction handle to clone for listener-independent + * use + * @return read transaction handle that is independent of the requests + * performed with the parameter + */ + ReadGraph getIndependentGraph(ReadGraph graph); + boolean hasParentRequest(ReadGraph graph); + +}