All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.alibaba.dts.sdk.DtsInnerSDKManager Maven / Gradle / Ivy
package com.alibaba.dts.sdk;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.Cookie;
import com.alibaba.dts.common.constants.Constants;
import com.alibaba.dts.common.domain.DtsUser;
import com.alibaba.dts.common.domain.result.Result;
import com.alibaba.dts.common.domain.store.Cluster;
import com.alibaba.dts.common.domain.store.Job;
import com.alibaba.dts.common.domain.store.assemble.AssembledMonitor;
import com.alibaba.dts.common.domain.store.assemble.AssembledUserGroup;
import com.alibaba.dts.common.domain.store.assemble.JobExecuteHistory;
import com.alibaba.dts.common.domain.store.assemble.JobInstanceDetailStatus;
import com.alibaba.dts.common.domain.store.assemble.JobStatus;
import com.alibaba.dts.common.domain.store.assemble.WarningNotifier;
import com.alibaba.dts.common.util.StringUtil;
import com.alibaba.dts.sdk.context.SDKContext;
import com.alibaba.dts.sdk.util.CookieUtil;
/**
* 内部环境SDK;
* Created by luliang on 15/1/21.
*/
public class DtsInnerSDKManager extends DtsCommonSDKManager {
/**
* 阿里云账户的用户名;
*/
private String userId;
public DtsInnerSDKManager(String userId) {
super();
if(StringUtil.isBlank(userId)) {
throw new RuntimeException("UserID不能为空!");
}
this.userId = userId;
}
public DtsInnerSDKManager(String userId, String url) {
super(url);
if(StringUtil.isBlank(userId)) {
throw new RuntimeException("UserID不能为空!");
}
this.userId = userId;
}
public static void main(String[] args) {
DtsInnerSDKManager dtsInnerSDKManager =new DtsInnerSDKManager("134778");
AssembledMonitor monitor = new AssembledMonitor();
monitor.setJobId(3787229);
//monitor.setPhoneWarning(true);
monitor.setTimeoutLimit(123);
monitor.setNotFireTimes(100);
monitor.setForcedTermination(true);
WarningNotifier warningNotifier = new WarningNotifier();
warningNotifier.setWwId("134778");
List warningNotifiers = new ArrayList();
warningNotifiers.add(warningNotifier);
monitor.setNotifiers(warningNotifiers);
dtsInnerSDKManager.setJobMonitorConfig(monitor);
}
@Deprecated
public DtsInnerSDKManager(String userId, SDKMode mode) {
super(mode);
if(StringUtil.isBlank(userId)) {
throw new RuntimeException("UserID不能为空!");
}
this.userId = userId;
}
@Override
public Result> getDtsClustersInfo() {
initRequest();
return super.getDtsClustersInfo();
}
@Override
public Result createGroup(long clusterId, String groupDescription) {
initRequest();
return super.createGroup(clusterId, groupDescription);
}
@Override
public Result deleteGroup(String userGroupId) {
initRequest();
return super.deleteGroup(userGroupId);
}
@Override
public Result> getUserGroups(long clusterId) {
initRequest();
return super.getUserGroups(clusterId);
}
@Override
public Result createJob(String userGroupId, Job job) {
initRequest();
return super.createJob(userGroupId, job);
}
@Override
public Result deleteJob(long jobId) {
initRequest();
return super.deleteJob(jobId);
}
@Override
public Result updateJob(String groupId, Job job) {
initRequest();
return super.updateJob(groupId, job);
}
public Result updateJobWithArguments(String groupId, Job job) {
initRequest();
return super.updateJobWithArguments(groupId, job);
}
@Override
public Result updateJobArguments(long jobId, String jobArguments) {
initRequest();
return super.updateJobArguments(jobId, jobArguments);
}
@Override
public Result> getJobsForGroup(String userGroupId) {
initRequest();
return super.getJobsForGroup(userGroupId);
}
public Result> getJobsForGroupByPage(String userGroupId, int pageSize, int pageNumber) {
initRequest();
return super.getJobsForGroupByPage(userGroupId, pageSize, pageNumber);
}
@Override
public Result enableJob(long jobId) {
initRequest();
return super.enableJob(jobId);
}
@Override
public Result disableJob(long jobId) {
initRequest();
return super.disableJob(jobId);
}
@Override
public Result instanceRunJob(String userGroupId, long jobId) {
initRequest();
return super.instanceRunJob(userGroupId, jobId);
}
public Result instanceRunJob(String userGroupId, long jobId, String instanceGlobal) {
initRequest();
return super.instanceRunJob(userGroupId, jobId, instanceGlobal);
}
@Override
public Result instanceStopJob(long jobId) {
initRequest();
return super.instanceStopJob(jobId);
}
@Override
public Result setJobMonitorConfig(AssembledMonitor monitorSeting) {
initRequest();
return super.setJobMonitorConfig(monitorSeting);
}
@Override
public Result updateJobMonitor(AssembledMonitor monitorSeting) {
initRequest();
return super.updateJobMonitor(monitorSeting);
}
@Override
public Result getMonitorSetings(long jobId) {
initRequest();
return super.getMonitorSetings(jobId);
}
@Override
public Result getJobRunningStatus(long jobId) {
initRequest();
return super.getJobRunningStatus(jobId);
}
@Override
public Result getJobDetailRunningStatus(long jobId, long instanceId) {
initRequest();
return super.getJobDetailRunningStatus(jobId, instanceId);
}
@Override
public Result getJobRunningHistoryStatusById(long jobId, long instanceId) {
initRequest();
return super.getJobRunningHistoryStatusById(jobId, instanceId);
}
@Override
public Result grantGroupAuth(String userGroupId, String ownerUserId, String grantUserId) {
initRequest();
return super.grantGroupAuth(userGroupId, ownerUserId, grantUserId);
}
@Override
public Result getJobRunningHistoryStatus(long jobId) {
initRequest();
return super.getJobRunningHistoryStatus(jobId);
}
@Override
public Result getJobConfig(long jobId) {
initRequest();
return super.getJobConfig(jobId);
}
public Result resetJobRelation(List startJobIdList) {
initRequest();
return super.resetJobRelation(startJobIdList);
}
public Result createRelation(long afterJobId, long beforeJobId) {
initRequest();
return super.createRelation(afterJobId, beforeJobId);
}
public Result deleteRelation(long afterJobId, long beforeJobId) {
initRequest();
return super.deleteRelation(afterJobId, beforeJobId);
}
public List queryClientGroupIpList(String groupId, long jobId) {
initRequest();
return super.queryClientGroupIpList(groupId, jobId);
}
public Result getJobRunningInformations(long jobInstanceId) {
initRequest();
return super.getJobRunningInformations(jobInstanceId);
}
public Result getJobLastInstanceId(long jobId) {
initRequest();
return super.getJobLastInstanceId(jobId);
}
/**
* 初始化cookie;
*/
private void initRequest() {
List cookies = new ArrayList(2);
Cookie sourceToken = new Cookie(Constants.USER_KEY, userId);
cookies.add(sourceToken);
cookies.add(new Cookie("defaultUser", new DtsUser(userId).toString()));
long nowTime = System.currentTimeMillis();
Cookie timestamp = new Cookie(Constants.TIME_STAMP, String.valueOf(nowTime));
cookies.add(timestamp);
SDKContext.setCookie(CookieUtil.cookieToString(cookies));
}
}