Search in sources :

Example 1 with QueryControlResult

use of edu.snu.mist.formats.avro.QueryControlResult in project mist by snuspl.

the class MISTQueryControl method delete.

/**
 * request task to delete the query.
 * TODO[MIST-290]: Return a message to Client.
 * @param queryId
 * @param taskAddress
 * @return It returns a result message of deletion.
 * @throws IOException
 */
public static APIQueryControlResult delete(final String groupId, final String queryId, final IPAddress taskAddress) throws IOException {
    final ClientToTaskMessage proxy = getProxy(taskAddress);
    final QueryControlResult queryControlResult = proxy.deleteQueries(groupId, queryId);
    final APIQueryControlResult apiQueryControlResult = new APIQueryControlResultImpl(queryControlResult.getQueryId(), taskAddress, queryControlResult.getMsg(), queryControlResult.getIsSuccess());
    return apiQueryControlResult;
}
Also used : ClientToTaskMessage(edu.snu.mist.formats.avro.ClientToTaskMessage) QueryControlResult(edu.snu.mist.formats.avro.QueryControlResult)

Example 2 with QueryControlResult

use of edu.snu.mist.formats.avro.QueryControlResult in project mist by snuspl.

the class GroupAwareQueryManagerImpl method delete.

/**
 * Deletes queries from MIST.
 */
@Override
public QueryControlResult delete(final String groupId, final String queryId) {
    groupMap.get(groupId).getApplicationInfo().getQueryRemover().deleteQuery(queryId);
    final QueryControlResult queryControlResult = new QueryControlResult();
    queryControlResult.setQueryId(queryId);
    queryControlResult.setIsSuccess(true);
    queryControlResult.setMsg(ResultMessage.deleteSuccess(queryId));
    return queryControlResult;
}
Also used : QueryControlResult(edu.snu.mist.formats.avro.QueryControlResult)

Example 3 with QueryControlResult

use of edu.snu.mist.formats.avro.QueryControlResult in project mist by snuspl.

the class GroupAwareQueryManagerImpl method createQueryWithCheckpoint.

@Override
public QueryControlResult createQueryWithCheckpoint(final AvroDag avroDag, final QueryCheckpoint checkpointedState) {
    final QueryControlResult queryControlResult = new QueryControlResult();
    final String queryId = avroDag.getQueryId();
    queryControlResult.setQueryId(queryId);
    try {
        // Create the submitted query
        // 1) Saves the avr dag to the PlanStore and
        // converts the avro dag to the logical and execution dag
        checkpointManager.storeQuery(avroDag);
        // Update app information
        final String appId = avroDag.getAppId();
        if (LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, "Create Query [aid: {0}, qid: {2}]", new Object[] { appId, queryId });
        }
        if (!applicationMap.containsKey(appId)) {
            createApplication(appId, avroDag.getJarPaths());
        }
        final ApplicationInfo applicationInfo = applicationMap.get(appId);
        final DAG<ConfigVertex, MISTEdge> configDag;
        if (checkpointedState == null) {
            configDag = configDagGenerator.generate(avroDag);
        } else {
            configDag = configDagGenerator.generateWithCheckpointedStates(avroDag, checkpointedState);
        }
        // Waiting for group information being added
        while (applicationInfo.getGroups().isEmpty()) {
            Thread.sleep(100);
        }
        final Query query = createAndStartQuery(queryId, applicationInfo, configDag);
        queryControlResult.setIsSuccess(true);
        queryControlResult.setMsg(ResultMessage.submitSuccess(queryId));
        return queryControlResult;
    } catch (final Exception e) {
        e.printStackTrace();
        // [MIST-345] We need to release all of the information that is required for the query when it fails.
        LOG.log(Level.SEVERE, "An exception occurred while starting {0} query: {1}", new Object[] { queryId, e.toString() });
        queryControlResult.setIsSuccess(false);
        queryControlResult.setMsg(e.getMessage());
        return queryControlResult;
    }
}
Also used : QueryControlResult(edu.snu.mist.formats.avro.QueryControlResult) MISTEdge(edu.snu.mist.common.graph.MISTEdge) IOException(java.io.IOException) InjectionException(org.apache.reef.tang.exceptions.InjectionException)

Aggregations

QueryControlResult (edu.snu.mist.formats.avro.QueryControlResult)3 MISTEdge (edu.snu.mist.common.graph.MISTEdge)1 ClientToTaskMessage (edu.snu.mist.formats.avro.ClientToTaskMessage)1 IOException (java.io.IOException)1 InjectionException (org.apache.reef.tang.exceptions.InjectionException)1