Compare commits

...

1 Commits

Author SHA1 Message Date
SunChaoqun
19fe33b3bb TESB-24409:Docker Image Support for Microservice Builds for Routes and
(Rest-) Data Services
2018-12-25 13:33:06 +08:00
6 changed files with 133 additions and 53 deletions

View File

@@ -387,6 +387,7 @@ JavaJobScriptsExportWSWizardPage.JBOSSESB=JBoss ESB (Deprecated)
JavaJobScriptsExportWSWizardPage.PETALSESB=Petals ESB (Deprecated)
JavaJobScriptsExportWSWizardPage.OSGI=OSGI Bundle For ESB
JavaJobScriptsExportWSWizardPage.MSESB=Microservice (Spring Boot) For ESB
JavaJobScriptsExportWSWizardPage.MSESB_IMAGE=Microservice (Spring Boot) For ESB Docker Image
JavaJobScriptsExportWSWizardPage.IMAGE=Docker Image
JavaJobScriptsExportWSWizardPage.DOCKER.optionGroup=Docker Options
JavaJobScriptsExportWSWizardPage.DOCKER.dockerHost=Docker host
@@ -405,6 +406,7 @@ JavaJobScriptsExportWSWizardPage.POJO.optionType.sources=Sources (Maven)
JavaJobScriptsExportWSWizardPage.banServiceJob=Service Job can't build independently but export with the Service node it assigned with.
LimitRESTRequestJobChecker.limit_tRESTRequest=ESB Job contains "{0}" should only build using one of [OSGI Bundle For ESB],[Microservice For ESB].
LimitRESTRequestJobChecker.limit_ESBJobForMS=Only ESB Job with "{0}" could build using [Microservice (Spring Boot) For ESB] type.
LimitRESTRequestJobChecker.limit_ESBJobForMSImage=Only ESB Job with "{0}" could build using [Microservice (Spring Boot) For ESB Docker Image] type.
LimitRESTRequestJobChecker.limit_ESBJobForOSGI=Job without ESB components could not build using [OSGI Bundle For ESB] type.
LimitESBConsumerJobChecker.limit_tRESTClient_tESBConsumer=ESB Job contains "{0}" should only build using one of [Standalone Job],[OSGI Bundle For ESB].
LimitESBConsumerJobChecker.limitFeaturesWithStandalone.locator=ESB Job contains "{0}" shouldn't specify feature Service Locator when build using [Standalone Job]

View File

@@ -91,6 +91,7 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
POJO(Messages.getString("JavaJobScriptsExportWSWizardPage.POJO"), false), //$NON-NLS-1$
OSGI(Messages.getString("JavaJobScriptsExportWSWizardPage.OSGI"), false), //$NON-NLS-1$
MSESB(Messages.getString("JavaJobScriptsExportWSWizardPage.MSESB"), false), //$NON-NLS-1$
MSESB_IMAGE(Messages.getString("JavaJobScriptsExportWSWizardPage.MSESB_IMAGE"), false), //$NON-NLS-1$
IMAGE(Messages.getString("JavaJobScriptsExportWSWizardPage.IMAGE"), false); //$NON-NLS-1$
public final String label;
@@ -515,7 +516,7 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
chkButton.setVisible(true);
zipOption = String.valueOf(chkButton.getSelection());
}
updateDestinationGroup(comboType == JobExportType.IMAGE);
updateDestinationGroup(comboType == JobExportType.IMAGE || comboType == JobExportType.MSESB_IMAGE);
checkExport();
}
});
@@ -935,9 +936,11 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
}
updateDestinationGroup(true);
contextButton.setSelection(settings.getBoolean(STORE_CONTEXT_ID));
applyToChildrenButton.setSelection(settings.getBoolean(APPLY_TO_CHILDREN_ID));
if (getCurrentExportType1() == JobExportType.IMAGE) {
applyToChildrenButton.setSelection(settings.getBoolean(APPLY_TO_CHILDREN_ID));
}
}
if (getProcessItem() != null && contextCombo != null) {
if (getProcessItem() != null && contextCombo != null && !contextCombo.isDisposed()) {
ProcessItem item = getProcessItem();
try {
String id = item.getProperty().getId();
@@ -952,7 +955,7 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
contextCombo.select(0);
}
}
if (log4jLevelCombo != null) {
if (log4jLevelCombo != null && !log4jLevelCombo.isDisposed()) {
log4jLevelCombo.setItems(Log4jPrefsSettingManager.getLevel());
if (Log4jPrefsSettingManager.getLevel().length > 0) {
log4jLevelCombo.select(2);
@@ -994,13 +997,14 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
if (getCurrentExportType1().equals(JobExportType.MSESB)) {
return;
}
if (getCurrentExportType1().equals(JobExportType.IMAGE)) {
if (getCurrentExportType1().equals(JobExportType.MSESB_IMAGE) || getCurrentExportType1().equals(JobExportType.IMAGE)) {
settings.put(STORE_DOCKER_IS_REMOTE_HOST, remoteRadio.getSelection());
if (remoteRadio.getSelection() && StringUtils.isNotBlank(hostText.getText())) {
settings.put(STORE_DOCKER_REMOTE_HOST, hostText.getText());
}
return;
}
if (contextButton != null) {
settings.put(STORE_CONTEXT_ID, contextButton.getSelection());
}
@@ -1064,6 +1068,10 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
return exportChoiceMap;
}
if (comboType.equals(JobExportType.MSESB_IMAGE)) {
return getExportChoiceMapForMSESBImage();
}
if (comboType.equals(JobExportType.IMAGE)) {
return getExportChoiceMapForImage();
}
@@ -1084,6 +1092,48 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
return exportChoiceMap;
}
private Map<ExportChoice, Object> getExportChoiceMapForMSESBImage() {
Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
exportChoiceMap.put(ExportChoice.buildImage, Boolean.TRUE);
exportChoiceMap.put(ExportChoice.needLauncher, Boolean.TRUE);
exportChoiceMap.put(ExportChoice.launcherName, JobScriptsManager.UNIX_ENVIRONMENT);
exportChoiceMap.put(ExportChoice.needSystemRoutine, Boolean.TRUE);
exportChoiceMap.put(ExportChoice.needUserRoutine, Boolean.TRUE);
exportChoiceMap.put(ExportChoice.needTalendLibraries, Boolean.TRUE);
exportChoiceMap.put(ExportChoice.needMetaInfo, true);
exportChoiceMap.put(ExportChoice.binaries, !isAddMavenScript());
// TDQ-15391: when have tDqReportRun, must always export items.
if (EmfModelUtils.getComponentByName(getProcessItem(), "tDqReportRun") != null) { //$NON-NLS-1$
exportChoiceMap.put(ExportChoice.needJobItem, Boolean.TRUE);
} else {
exportChoiceMap.put(ExportChoice.needJobItem, Boolean.FALSE);
}
// TDQ-15391~
exportChoiceMap.put(ExportChoice.needSourceCode, Boolean.FALSE);
exportChoiceMap.put(ExportChoice.needDependencies, Boolean.TRUE);
exportChoiceMap.put(ExportChoice.needJobScript, Boolean.FALSE);
exportChoiceMap.put(ExportChoice.needAssembly, Boolean.TRUE);
exportChoiceMap.put(ExportChoice.needContext, true);
exportChoiceMap.put(ExportChoice.contextName, getContextName());
if (remoteRadio.getSelection()) {
String host = hostText.getText();
if (!StringUtils.isBlank(host)) {
exportChoiceMap.put(ExportChoice.dockerHost, host);
}
}
String imageName = imageText.getText();
if (!StringUtils.isBlank(imageName)) {
exportChoiceMap.put(ExportChoice.imageName, imageName);
}
String imageTag = tagText.getText();
if (!StringUtils.isBlank(imageTag)) {
exportChoiceMap.put(ExportChoice.imageTag, imageTag);
}
return exportChoiceMap;
}
private Map<ExportChoice, Object> getExportChoiceMapForImage() {
Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
exportChoiceMap.put(ExportChoice.buildImage, Boolean.TRUE);
@@ -1184,6 +1234,13 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
createOptionsForMSESB(left, font);
restoreWidgetValuesForOSGI();
break;
case MSESB_IMAGE:
createOptionsForMSESB(left, font);
createDockerOptions();
restoreWidgetValuesForImage();
addDockerOptionsListener();
contextButton.setSelection(false);
break;
case IMAGE:
createOptionForDockerImage(left, font);
createDockerOptions();
@@ -1238,31 +1295,33 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
if (!PluginChecker.isTIS()) {
return;
}
if (getCurrentExportType1() != JobExportType.MSESB_IMAGE) {
addBSButton = new Button(optionsComposite, SWT.CHECK | SWT.LEFT);
addBSButton.setText("Add maven script"); //$NON-NLS-1$
addBSButton.setFont(font);
addBSButton = new Button(optionsComposite, SWT.CHECK | SWT.LEFT);
addBSButton.setText("Add maven script"); //$NON-NLS-1$
addBSButton.setFont(font);
addBSButton.addSelectionListener(new SelectionAdapter() {
addBSButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean show = addBSButton.getSelection();
String destinationValue = getDestinationValue();
if (destinationValue.endsWith(getOutputSuffix())) {
if (show) {
destinationValue = destinationValue.substring(0, destinationValue.indexOf(getOutputSuffix()))
+ OUTPUT_FILE_SUFFIX;
}
} else if (destinationValue.endsWith(OUTPUT_FILE_SUFFIX)) {
if (!show) {
destinationValue = destinationValue.substring(0, destinationValue.indexOf(OUTPUT_FILE_SUFFIX))
+ getOutputSuffix();
@Override
public void widgetSelected(SelectionEvent e) {
boolean show = addBSButton.getSelection();
String destinationValue = getDestinationValue();
if (destinationValue.endsWith(getOutputSuffix())) {
if (show) {
destinationValue = destinationValue.substring(0, destinationValue.indexOf(getOutputSuffix()))
+ OUTPUT_FILE_SUFFIX;
}
} else if (destinationValue.endsWith(OUTPUT_FILE_SUFFIX)) {
if (!show) {
destinationValue = destinationValue.substring(0, destinationValue.indexOf(OUTPUT_FILE_SUFFIX))
+ getOutputSuffix();
}
}
setDestinationValue(destinationValue);
}
setDestinationValue(destinationValue);
}
});
});
}
contextButton = new Button(optionsComposite, SWT.CHECK | SWT.LEFT);
contextButton.setText("Only export the default context"); //$NON-NLS-1$
@@ -1276,36 +1335,37 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
// onlyExportDefaultContext = contextButton.getSelection();
}
});
if (getCurrentExportType1() != JobExportType.MSESB_IMAGE) {
exportMSAsZipButton = new Button(optionsComposite, SWT.CHECK | SWT.LEFT);
exportMSAsZipButton.setText("Export as ZIP"); //$NON-NLS-1$
exportMSAsZipButton.setFont(getFont());
// exportAsZipButton.setEnabled(false);
exportMSAsZipButton.setVisible(PluginChecker.isTIS());
exportMSAsZipButton.addSelectionListener(new SelectionAdapter() {
exportMSAsZipButton = new Button(optionsComposite, SWT.CHECK | SWT.LEFT);
exportMSAsZipButton.setText("Export as ZIP"); //$NON-NLS-1$
exportMSAsZipButton.setFont(getFont());
// exportAsZipButton.setEnabled(false);
exportMSAsZipButton.setVisible(PluginChecker.isTIS());
exportMSAsZipButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean selectContext = exportMSAsZipButton.getSelection();
// exportAsZip = selectContext;
@Override
public void widgetSelected(SelectionEvent e) {
boolean selectContext = exportMSAsZipButton.getSelection();
// exportAsZip = selectContext;
String destinationValue = getDestinationValue();
if (destinationValue.endsWith(getOutputSuffix())) {
if (selectContext) {
destinationValue = destinationValue.substring(0, destinationValue.indexOf(getOutputSuffix()))
+ OUTPUT_FILE_SUFFIX;
}
} else if (destinationValue.endsWith(OUTPUT_FILE_SUFFIX)) {
if (!selectContext) {
destinationValue = destinationValue.substring(0, destinationValue.indexOf(OUTPUT_FILE_SUFFIX))
+ getOutputSuffix();
String destinationValue = getDestinationValue();
if (destinationValue.endsWith(getOutputSuffix())) {
if (selectContext) {
destinationValue = destinationValue.substring(0, destinationValue.indexOf(getOutputSuffix()))
+ OUTPUT_FILE_SUFFIX;
}
} else if (destinationValue.endsWith(OUTPUT_FILE_SUFFIX)) {
if (!selectContext) {
destinationValue = destinationValue.substring(0, destinationValue.indexOf(OUTPUT_FILE_SUFFIX))
+ getOutputSuffix();
}
}
setDestinationValue(destinationValue);
}
setDestinationValue(destinationValue);
}
});
});
}
}
private void createOptionsForOSGIESB(Composite optionsComposite, Font font) {

View File

@@ -1386,7 +1386,8 @@ public abstract class JobScriptsExportWizardPage extends WizardFileSystemResourc
JobExportType jobExportType = getCurrentExportType1();
if (JobExportType.POJO.equals(jobExportType) || JobExportType.MSESB.equals(jobExportType)
|| JobExportType.OSGI.equals(jobExportType) || JobExportType.IMAGE.equals(jobExportType)) {
|| JobExportType.OSGI.equals(jobExportType) || JobExportType.IMAGE.equals(jobExportType)
|| JobExportType.MSESB_IMAGE.equals(jobExportType)) {
IRunnableWithProgress worker = new IRunnableWithProgress() {
@Override

View File

@@ -43,6 +43,13 @@ public class LimitRESTRequestJobChecker extends AbstractJobNodeChecker {
return null;
}
if (exportType == JobExportType.MSESB_IMAGE) {
if (T_REST_REQUEST.equals(componentName)) {
tRESTRequestExist = true;
}
return null;
}
if (T_REST_REQUEST.equals(componentName)) {
return Messages.getString("LimitRESTRequestJobChecker.limit_tRESTRequest", componentName);
}
@@ -74,6 +81,10 @@ public class LimitRESTRequestJobChecker extends AbstractJobNodeChecker {
if (!tRESTRequestExist) {
return Messages.getString("LimitRESTRequestJobChecker.limit_ESBJobForMS", T_REST_REQUEST);
}
} else if (exportType == JobExportType.MSESB_IMAGE) {
if (!tRESTRequestExist) {
return Messages.getString("LimitRESTRequestJobChecker.limit_ESBJobForMSImage", T_REST_REQUEST);
}
}
return null;

View File

@@ -46,6 +46,7 @@ public class BuildJobFactory {
oldBuildTypeMap.put(JobExportType.POJO, "STANDALONE");
oldBuildTypeMap.put(JobExportType.OSGI, "OSGI");
oldBuildTypeMap.put(JobExportType.MSESB, "REST_MS");
oldBuildTypeMap.put(JobExportType.MSESB_IMAGE, "REST_MS");
esbComponents = Collections.unmodifiableList(Arrays.asList("tRESTClient", "tRESTRequest", "tRESTResponse", "tESBConsumer",
"tESBProviderFault", "tESBProviderRequest", "tESBProviderResponse", "tRouteInput", "tREST"));
}
@@ -70,6 +71,8 @@ public class BuildJobFactory {
case OSGI:
break; // continue
case MSESB:
break; // continue、
case MSESB_IMAGE:
break; // continue
default:
jobExportType = null; // try the first one by default

View File

@@ -54,6 +54,9 @@ public class JobScriptsManagerFactory {
case MSESB:
ProcessorUtilities.setExportJobAsMicroSerivce(true);
return new JobJavaScriptMicroServiceForESBManager(exportChoiceMap, contextName, launcher, statisticPort, tracePort);
case MSESB_IMAGE:
ProcessorUtilities.setExportJobAsMicroSerivce(true);
return new JobJavaScriptMicroServiceForESBManager(exportChoiceMap, contextName, launcher, statisticPort, tracePort);
default:
//
}