-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from Davidhua1996/dev-1.0.0
LGTM
- Loading branch information
Showing
10 changed files
with
224 additions
and
60 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
76 changes: 76 additions & 0 deletions
76
...webank/wedatasphere/exchangis/job/server/builder/ServiceInExchangisJobBuilderContext.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,76 @@ | ||
package com.webank.wedatasphere.exchangis.job.server.builder; | ||
|
||
import com.webank.wedatasphere.exchangis.datasource.core.service.MetadataInfoService; | ||
import com.webank.wedatasphere.exchangis.job.builder.ExchangisJobBuilderContext; | ||
import com.webank.wedatasphere.exchangis.job.builder.api.ExchangisJobBuilder; | ||
import com.webank.wedatasphere.exchangis.job.domain.ExchangisJobInfo; | ||
import com.webank.wedatasphere.exchangis.job.listener.JobLogListener; | ||
import com.webank.wedatasphere.exchangis.job.listener.events.JobLogEvent; | ||
import com.webank.wedatasphere.exchangis.job.server.log.JobServerLogging; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Service in job builder context | ||
*/ | ||
public class ServiceInExchangisJobBuilderContext extends ExchangisJobBuilderContext { | ||
|
||
/** | ||
* Meta info service | ||
*/ | ||
private MetadataInfoService metadataInfoService; | ||
|
||
/** | ||
* Job execution id | ||
*/ | ||
private String jobExecutionId; | ||
|
||
/** | ||
* Logging | ||
*/ | ||
private JobServerLogging<ExchangisJobBuilder<?, ?>> logging; | ||
|
||
public ServiceInExchangisJobBuilderContext(ExchangisJobInfo originalJob, | ||
JobLogListener jobLogListener) { | ||
super(originalJob); | ||
this.logging = new JobServerLogging<ExchangisJobBuilder<?, ?>>() { | ||
@Override | ||
public Logger getLogger() { | ||
return Objects.nonNull(currentBuilder)? | ||
LoggerFactory.getLogger(currentBuilder.getClass()) : null; | ||
} | ||
|
||
@Override | ||
public JobLogListener getJobLogListener() { | ||
return jobLogListener; | ||
} | ||
|
||
@Override | ||
public JobLogEvent getJobLogEvent(JobLogEvent.Level level, ExchangisJobBuilder<?, ?> builder, String message, Object... args) { | ||
return new JobLogEvent(level, originalJob.getExecuteUser(), jobExecutionId, message, args); | ||
} | ||
}; | ||
} | ||
|
||
public String getJobExecutionId() { | ||
return jobExecutionId; | ||
} | ||
|
||
public void setJobExecutionId(String jobExecutionId) { | ||
this.jobExecutionId = jobExecutionId; | ||
} | ||
|
||
public MetadataInfoService getMetadataInfoService() { | ||
return metadataInfoService; | ||
} | ||
|
||
public void setMetadataInfoService(MetadataInfoService metadataInfoService) { | ||
this.metadataInfoService = metadataInfoService; | ||
} | ||
|
||
public JobServerLogging<ExchangisJobBuilder<?, ?>> getLogging() { | ||
return logging; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
.../wedatasphere/exchangis/job/server/builder/engine/AbstractLoggingExchangisJobBuilder.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,52 @@ | ||
package com.webank.wedatasphere.exchangis.job.server.builder.engine; | ||
|
||
import com.webank.wedatasphere.exchangis.job.builder.ExchangisJobBuilderContext; | ||
import com.webank.wedatasphere.exchangis.job.builder.api.AbstractExchangisJobBuilder; | ||
import com.webank.wedatasphere.exchangis.job.domain.ExchangisBase; | ||
import com.webank.wedatasphere.exchangis.job.domain.ExchangisJob; | ||
import com.webank.wedatasphere.exchangis.job.exception.ExchangisJobException; | ||
import com.webank.wedatasphere.exchangis.job.server.builder.ServiceInExchangisJobBuilderContext; | ||
|
||
/** | ||
* Abstract implement for engine job builder | ||
*/ | ||
public abstract class AbstractLoggingExchangisJobBuilder<T extends ExchangisJob, E extends ExchangisBase> extends | ||
AbstractExchangisJobBuilder<T, E> { | ||
|
||
/** | ||
* Get builder context | ||
* @return context | ||
* @throws ExchangisJobException.Runtime exception | ||
*/ | ||
protected static ServiceInExchangisJobBuilderContext getServiceInBuilderContext() throws ExchangisJobException.Runtime{ | ||
ExchangisJobBuilderContext context = getCurrentBuilderContext(); | ||
if (!(context instanceof ServiceInExchangisJobBuilderContext)) { | ||
throw new ExchangisJobException.Runtime(-1, "The job builder context cannot not be casted to " + ServiceInExchangisJobBuilderContext.class.getCanonicalName(), null); | ||
} | ||
return (ServiceInExchangisJobBuilderContext)context; | ||
} | ||
|
||
/** | ||
* Warn message | ||
* @param message message | ||
*/ | ||
public static void warn(String message, Object... args){ | ||
getServiceInBuilderContext().getLogging().warn(null, message, args); | ||
} | ||
|
||
public static void warn(String message, Throwable t){ | ||
getServiceInBuilderContext().getLogging().warn(null, message, t); | ||
} | ||
|
||
/** | ||
* Info message | ||
* @param message message | ||
*/ | ||
public static void info(String message, Object... args){ | ||
getServiceInBuilderContext().getLogging().info(null, message, args); | ||
} | ||
|
||
public static void info(String message, Throwable t){ | ||
getServiceInBuilderContext().getLogging().info(null, message, t); | ||
} | ||
} |
Oops, something went wrong.