-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HWKMETRICS-52] initial support for scheduling and retrieving tasks
- Loading branch information
John Sanda
committed
May 12, 2015
1 parent
9797214
commit dbb682c
Showing
14 changed files
with
421 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
task-queue/src/main/java/org/hawkular/metrics/tasks/Task.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* | ||
* * 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; | ||
|
||
import static org.joda.time.Minutes.minutes; | ||
|
||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import org.joda.time.Duration; | ||
|
||
/** | ||
* @author jsanda | ||
*/ | ||
public class Task { | ||
|
||
private TaskDef taskDef; | ||
|
||
private String target; | ||
|
||
private Set<String> sources; | ||
|
||
private Duration interval; | ||
|
||
private Duration window; | ||
|
||
public Task() { | ||
} | ||
|
||
public Task(TaskDef taskDef, String target, Set<String> sources, int interval, int window) { | ||
this.taskDef = taskDef; | ||
this.target = target; | ||
this.sources = sources; | ||
this.interval = minutes(interval).toStandardDuration(); | ||
this.window = minutes(window).toStandardDuration(); | ||
} | ||
|
||
public Task(TaskDef taskDef, String target, String source, int interval, int window) { | ||
this.taskDef = taskDef; | ||
this.target = target; | ||
this.sources = ImmutableSet.of(source); | ||
this.interval = minutes(interval).toStandardDuration(); | ||
this.window = minutes(window).toStandardDuration(); | ||
} | ||
|
||
public TaskDef getTaskDef() { | ||
return taskDef; | ||
} | ||
|
||
public String getTarget() { | ||
return target; | ||
} | ||
|
||
public Set<String> getSources() { | ||
return sources; | ||
} | ||
|
||
public Duration getInterval() { | ||
return interval; | ||
} | ||
|
||
public Duration getWindow() { | ||
return window; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Task task = (Task) o; | ||
return Objects.equals(taskDef, task.taskDef) && | ||
Objects.equals(target, task.target) && | ||
Objects.equals(sources, task.sources) && | ||
Objects.equals(interval, task.interval) && | ||
Objects.equals(window, task.window); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(taskDef, target, sources, interval, window); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
task-queue/src/main/java/org/hawkular/metrics/tasks/TaskDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* | ||
* * 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; | ||
|
||
import java.util.Objects; | ||
|
||
import com.google.common.base.Supplier; | ||
|
||
/** | ||
* @author jsanda | ||
*/ | ||
public class TaskDef { | ||
|
||
private String name; | ||
|
||
private Supplier<Runnable> factory; | ||
|
||
private int segments; | ||
|
||
private int segmentOffsets; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public TaskDef setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public Supplier<Runnable> getFactory() { | ||
return factory; | ||
} | ||
|
||
public TaskDef setFactory(Supplier<Runnable> factory) { | ||
this.factory = factory; | ||
return this; | ||
} | ||
|
||
public int getSegments() { | ||
return segments; | ||
} | ||
|
||
public TaskDef setSegments(int segments) { | ||
this.segments = segments; | ||
return this; | ||
} | ||
|
||
public int getSegmentOffsets() { | ||
return segmentOffsets; | ||
} | ||
|
||
public TaskDef setSegmentOffsets(int segmentOffsets) { | ||
this.segmentOffsets = segmentOffsets; | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
TaskDef taskDef = (TaskDef) o; | ||
return Objects.equals(name, taskDef.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name); | ||
} | ||
} |
Oops, something went wrong.