This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving the existing src to fenzo-core and added subproject for fenzo-…
…triggers
- Loading branch information
Satyajit Thadeshwar
committed
Mar 18, 2015
1 parent
82943e2
commit c682d6c
Showing
81 changed files
with
1,538 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,46 @@ | ||
plugins { | ||
id 'nebula.netflixoss' version '2.2.9' | ||
id 'java' | ||
/* | ||
* Copyright 2015 Netflix, Inc. | ||
* | ||
* 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. | ||
*/ | ||
|
||
buildscript { | ||
repositories { jcenter() } | ||
dependencies { | ||
classpath 'com.netflix.nebula:gradle-netflixoss-project-plugin:2.2.8' | ||
} | ||
} | ||
|
||
// Establish version and status | ||
ext.githubProjectName = 'Fenzo' | ||
|
||
group = 'com.netflix.fenzo' | ||
|
||
repositories { | ||
jcenter() | ||
allprojects { | ||
apply plugin: 'nebula.netflixoss' | ||
apply plugin: 'idea' | ||
|
||
group = 'com.netflix.fenzo' | ||
sourceCompatibility = 1.7 | ||
targetCompatibility = 1.7 | ||
} | ||
|
||
sourceCompatibility = 1.7 | ||
targetCompatibility = 1.7 | ||
subprojects { | ||
repositories { jcenter() } | ||
|
||
apply plugin: 'dependency-lock' | ||
apply plugin: 'java' | ||
apply plugin: 'groovy' | ||
|
||
dependencies { | ||
compile 'io.reactivex:rxjava:1.0.4' | ||
compile 'org.apache.mesos:mesos:0.18.0' | ||
compile 'org.slf4j:slf4j-api:1.7.0' | ||
testCompile 'junit:junit-dep:4.10' | ||
testCompile 'org.mockito:mockito-core:1.8.5' | ||
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.5' | ||
dependencies { | ||
compile ("org.slf4j:slf4j-api:latest.release") | ||
compile ("org.slf4j:slf4j-simple:latest.release") | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"org.slf4j:slf4j-api": { "locked": "1.7.10", "requested": "1.7.10" }, | ||
"org.slf4j:slf4j-simple": { "locked": "1.7.10", "requested": "1.7.10" }, | ||
"io.reactivex:rxjava": { "locked": "1.0.4", "requested": "1.0.4" }, | ||
"org.apache.mesos:mesos": { "locked": "0.18.0", "requested": "0.18.0" }, | ||
"junit:junit-dep": { "locked": "4.10", "requested": "4.10" }, | ||
"org.mockito:mockito-core": { "locked": "1.8.5", "requested": "1.8.5" }, | ||
"com.fasterxml.jackson.core:jackson-databind": { "locked": "2.4.5", "requested": "2.4.5" } | ||
} |
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,7 @@ | ||
dependencies { | ||
compile ("io.reactivex:rxjava:latest.release") | ||
compile ("org.apache.mesos:mesos:latest.release") | ||
compile ("com.fasterxml.jackson.core:jackson-databind:latest.release") | ||
testCompile ("junit:junit-dep:latest.release") | ||
testCompile ("org.mockito:mockito-core:latest.release") | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,5 @@ | ||
{ | ||
"org.slf4j:slf4j-api": { "locked": "1.7.10", "requested": "1.7.10" }, | ||
"org.slf4j:slf4j-simple": { "locked": "1.7.10", "requested": "1.7.10" }, | ||
"org.quartz-scheduler:quartz": { "locked": "2.2.1", "requested": "2.2.1" }, | ||
} |
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,19 @@ | ||
/* | ||
* Copyright 2015 Netflix, Inc. | ||
* | ||
* 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. | ||
*/ | ||
|
||
dependencies { | ||
compile ("org.quartz-scheduler:quartz:latest.release") | ||
} |
39 changes: 39 additions & 0 deletions
39
fenzo-triggers/src/main/java/com/netflix/fenzo/triggers/ApplicationTrigger.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,39 @@ | ||
package com.netflix.fenzo.triggers; | ||
|
||
/** | ||
* | ||
*/ | ||
public class ApplicationTrigger extends Trigger { | ||
|
||
private String applicationName; | ||
|
||
protected ApplicationTrigger(Builder builder) { | ||
super(builder); | ||
this.applicationName = builder.applicationName; | ||
} | ||
|
||
public static Builder<?> newTrigger() { | ||
return new Builder(); | ||
} | ||
|
||
public String getApplicationName() { | ||
return applicationName; | ||
} | ||
|
||
public String toString() { | ||
return "ApplicationTrigger (" + applicationName + ":" + getId() + ":" + getName() + ")"; | ||
} | ||
|
||
public static class Builder<T extends Builder<T>> extends Trigger.Builder<T> { | ||
private String applicationName; | ||
|
||
public T withApplicationName(String applicationName) { | ||
this.applicationName = applicationName; | ||
return self(); | ||
} | ||
|
||
public ApplicationTrigger build() { | ||
return new ApplicationTrigger(this); | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
fenzo-triggers/src/main/java/com/netflix/fenzo/triggers/CronTrigger.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,51 @@ | ||
package com.netflix.fenzo.triggers; | ||
|
||
/** | ||
* | ||
*/ | ||
public class CronTrigger extends ScheduledTrigger { | ||
private String cronExpression; | ||
private org.quartz.CronTrigger cronTrigger; | ||
|
||
protected CronTrigger(Builder builder) { | ||
super(builder); | ||
this.cronExpression = builder.cronExpression; | ||
} | ||
|
||
public String getCronExpression() { | ||
return cronExpression; | ||
} | ||
|
||
public void setCronExpression(String cronExpression) { | ||
this.cronExpression = cronExpression; | ||
} | ||
|
||
public org.quartz.CronTrigger getCronTrigger() { | ||
return cronTrigger; | ||
} | ||
|
||
public void setCronTrigger(org.quartz.CronTrigger cronTrigger) { | ||
this.cronTrigger = cronTrigger; | ||
} | ||
|
||
public static Builder<?> newTrigger() { | ||
return new Builder(); | ||
} | ||
|
||
public String toString() { | ||
return "CronTrigger (" + getId() + ":" + getName() + ":" + cronExpression + ")"; | ||
} | ||
|
||
public static class Builder<T extends Builder<T>> extends ScheduledTrigger.Builder<T> { | ||
private String cronExpression; | ||
|
||
public T withCronExpression(String cronExpression) { | ||
this.cronExpression = cronExpression; | ||
return self(); | ||
} | ||
|
||
public CronTrigger build() { | ||
return new CronTrigger(this); | ||
} | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
fenzo-triggers/src/main/java/com/netflix/fenzo/triggers/Event.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,123 @@ | ||
package com.netflix.fenzo.triggers; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* | ||
*/ | ||
public class Event { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(Event.class); | ||
|
||
private final String id; | ||
private final Trigger trigger; | ||
private final Job job; | ||
private Date startTime; | ||
private Date endTime; | ||
private Status status; | ||
|
||
public Event(Trigger trigger, Job job) { | ||
this.id = UUID.randomUUID().toString(); | ||
this.trigger = trigger; | ||
this.job = job; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public Trigger getTrigger() { | ||
return trigger; | ||
} | ||
|
||
public Date getStartTime() { | ||
return startTime; | ||
} | ||
|
||
public void setStartTime(Date startTime) { | ||
this.startTime = startTime; | ||
} | ||
|
||
public Date getEndTime() { | ||
return endTime; | ||
} | ||
|
||
public void setEndTime(Date endTime) { | ||
this.endTime = endTime; | ||
} | ||
|
||
public void setStatus(Status status) { | ||
this.status = status; | ||
} | ||
|
||
public Job getJob() { | ||
return job; | ||
} | ||
|
||
public List<String> getExecutionLog() { | ||
return job.getExecutionLog(); | ||
} | ||
|
||
public Status getStatus() { | ||
if (this.status == Status.IN_PROGRESS || this.status == Status.FAILED || this.status == Status.CANCELLED) { | ||
return this.status; | ||
} else { | ||
Status jobStatus = job.getStatus(); | ||
return jobStatus != null ? jobStatus : this.status; | ||
} | ||
} | ||
|
||
public List<String> getOwners() { | ||
List<String> owners = job.getOwners(); | ||
return owners == null ? trigger.getOwners() : owners; | ||
} | ||
|
||
public List<String> getWatchers() { | ||
List<String> watchers = job.getWatchers(); | ||
return watchers == null ? trigger.getWatchers() : watchers; | ||
} | ||
|
||
public void notifyForEventStart(List<String> owners, List<String> watchers) { | ||
try { | ||
job.notifyForEventStart(owners, watchers); | ||
} catch (Exception e) { | ||
logger.error("Exception occurred in notifyForEventStart() method for {}", this, e); | ||
} | ||
} | ||
|
||
public void notifyForEventEnd(List<String> owners, List<String> watchers) { | ||
try { | ||
job.notifyForEventEnd(owners, watchers); | ||
} catch (Exception e) { | ||
logger.error("Exception occurred in notifyForEventEnd() method for {}", this, e); | ||
} | ||
} | ||
|
||
public void notifyForError(List<String> owners, List<String> watchers, Throwable throwable) { | ||
try { | ||
job.notifyForError(owners, watchers, throwable); | ||
} catch (Exception e) { | ||
logger.error("Exception occurred in notifyForError() method for {}", this, e); | ||
} | ||
} | ||
|
||
public void notifyForEventCancel(List<String> owners, List<String> watchers) { | ||
try { | ||
job.notifyForEventCancel(owners, watchers); | ||
} catch (Exception e) { | ||
logger.error("Exception occurred in notifyForEventCancel() method for {}", this, e); | ||
} | ||
} | ||
|
||
public void execute(Map<String,Object> params) throws Exception { | ||
job.execute(params); | ||
} | ||
|
||
public void cancel() throws Exception { | ||
job.cancel(); | ||
} | ||
|
||
} |
Oops, something went wrong.