
org.hawkular.metrics.tasks.impl.Queries Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2014-2015 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed 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.hawkular.metrics.tasks.impl;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.Session;
/**
* @author jsanda
*/
public class Queries {
public PreparedStatement createLease;
public PreparedStatement findLeases;
public PreparedStatement acquireLease;
public PreparedStatement renewLease;
public PreparedStatement finishLease;
public PreparedStatement deleteLeases;
public PreparedStatement createTask;
public PreparedStatement createTask2;
public PreparedStatement insertIntoQueue;
public PreparedStatement getTasksFromQueue;
public PreparedStatement createTaskWithFailures;
public PreparedStatement findTasks;
public PreparedStatement findTask;
public PreparedStatement deleteTasks;
public Queries(Session session) {
createLease = session.prepare(
"INSERT INTO leases (time_slice, shard) VALUES (?, ?)");
findLeases = session.prepare(
"SELECT shard, owner, finished FROM leases WHERE time_slice = ?");
acquireLease = session.prepare(
"UPDATE leases " +
"USING TTL ? " +
"SET owner = ? " +
"WHERE time_slice = ? AND shard = ? " +
"IF owner = NULL");
//
// renewLease = session.prepare(
// "UPDATE leases " +
// "USING TTL ? " +
// "SET owner = ? " +
// "WHERE time_slice = ? AND task_type = ? AND segment_offset = ? " +
// "IF owner = ?");
//
finishLease = session.prepare(
"UPDATE leases " +
"SET finished = true " +
"WHERE time_slice = ? AND shard = ?");
//
deleteLeases = session.prepare("DELETE FROM leases WHERE time_slice = ?");
// createTask = session.prepare(
// "INSERT INTO task_queue (task_type, tenant_id, time_slice, segment, target, sources, interval, window) " +
// "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
createTask2 = session.prepare(
"INSERT INTO tasks (id, group_key, exec_order, name, params, trigger) VALUES (?, ?, ?, ?, ?, ?)");
insertIntoQueue = session.prepare(
"INSERT INTO task_queue (time_slice, shard, task_id, group_key, exec_order, task_name, task_params, " +
"trigger) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
getTasksFromQueue = session.prepare(
"SELECT group_key, exec_order, task_id, task_name, task_params, trigger " +
"FROM task_queue " +
"WHERE time_slice = ? AND shard = ?");
// createTaskWithFailures = session.prepare(
// "INSERT INTO task_queue (task_type, tenant_id, time_slice, segment, target, sources, interval, window, " +
// "failed_time_slices) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
// findTasks = session.prepare(
// "SELECT tenant_id, target, sources, interval, window, failed_time_slices " +
// "FROM task_queue " +
// "WHERE task_type = ? AND time_slice = ? AND segment = ?");
findTask = session.prepare("SELECT group_key, exec_order, name, params, trigger FROM tasks WHERE id = ?");
deleteTasks = session.prepare("DELETE FROM task_queue WHERE time_slice = ? AND shard = ?");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy