Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
Moving the existing src to fenzo-core and added subproject for fenzo-…
Browse files Browse the repository at this point in the history
…triggers
  • Loading branch information
Satyajit Thadeshwar committed Mar 18, 2015
1 parent 82943e2 commit c682d6c
Show file tree
Hide file tree
Showing 81 changed files with 1,538 additions and 17 deletions.
55 changes: 38 additions & 17 deletions build.gradle
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")
}
}
9 changes: 9 additions & 0 deletions fenzo-core/dependencies.lock
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" }
}
7 changes: 7 additions & 0 deletions fenzo-core/fenzo-core.gradle
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")
}
5 changes: 5 additions & 0 deletions fenzo-triggers/dependencies.lock
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" },
}
19 changes: 19 additions & 0 deletions fenzo-triggers/fenzo-triggers.gradle
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")
}
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);
}
}
}
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 fenzo-triggers/src/main/java/com/netflix/fenzo/triggers/Event.java
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();
}

}
Loading

0 comments on commit c682d6c

Please sign in to comment.