mirror of
https://github.com/apache/sqoop.git
synced 2025-05-17 09:20:43 +08:00
SQOOP-920: Sqoop2: Print out warnings in client shell for objects created with status ACCEPTABLE
(Vasanth kumar RJ via Jarek Jarcec Cecho)
This commit is contained in:
parent
3fd8bdffc9
commit
1a77317969
@ -347,6 +347,9 @@ public class Constants {
|
|||||||
public static final String RES_FORMDISPLAYER_INPUT_SENSITIVE =
|
public static final String RES_FORMDISPLAYER_INPUT_SENSITIVE =
|
||||||
"formdisplayer.input_sensitive";
|
"formdisplayer.input_sensitive";
|
||||||
|
|
||||||
|
public static final String RES_FORMDISPLAYER_FORM_WARNING =
|
||||||
|
"formdisplayer.warning_message";
|
||||||
|
|
||||||
private Constants() {
|
private Constants() {
|
||||||
// Instantiation is prohibited
|
// Instantiation is prohibited
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
import org.apache.commons.cli.OptionBuilder;
|
import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.sqoop.client.core.ClientError;
|
import org.apache.sqoop.client.core.ClientError;
|
||||||
import org.apache.sqoop.client.core.Constants;
|
import org.apache.sqoop.client.core.Constants;
|
||||||
|
import org.apache.sqoop.client.utils.FormDisplayer;
|
||||||
import org.apache.sqoop.common.SqoopException;
|
import org.apache.sqoop.common.SqoopException;
|
||||||
import org.apache.sqoop.model.MConnection;
|
import org.apache.sqoop.model.MConnection;
|
||||||
import org.apache.sqoop.validation.Status;
|
import org.apache.sqoop.validation.Status;
|
||||||
@ -86,7 +87,7 @@ private void createConnection(long connectorId) throws IOException {
|
|||||||
// Try to create
|
// Try to create
|
||||||
status = client.createConnection(connection);
|
status = client.createConnection(connection);
|
||||||
} while(!status.canProceed());
|
} while(!status.canProceed());
|
||||||
|
FormDisplayer.displayFormWarning(connection);
|
||||||
printlnResource(Constants.RES_CREATE_CONN_SUCCESSFUL, status.name(), connection.getPersistenceId());
|
printlnResource(Constants.RES_CREATE_CONN_SUCCESSFUL, status.name(), connection.getPersistenceId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
import org.apache.commons.cli.OptionBuilder;
|
import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.sqoop.client.core.ClientError;
|
import org.apache.sqoop.client.core.ClientError;
|
||||||
import org.apache.sqoop.client.core.Constants;
|
import org.apache.sqoop.client.core.Constants;
|
||||||
|
import org.apache.sqoop.client.utils.FormDisplayer;
|
||||||
import org.apache.sqoop.common.SqoopException;
|
import org.apache.sqoop.common.SqoopException;
|
||||||
import org.apache.sqoop.model.MJob;
|
import org.apache.sqoop.model.MJob;
|
||||||
import org.apache.sqoop.validation.Status;
|
import org.apache.sqoop.validation.Status;
|
||||||
@ -99,7 +100,7 @@ private void createJob(Long connectionId, String type) throws IOException {
|
|||||||
// Try to create
|
// Try to create
|
||||||
status = client.createJob(job);
|
status = client.createJob(job);
|
||||||
} while(!status.canProceed());
|
} while(!status.canProceed());
|
||||||
|
FormDisplayer.displayFormWarning(job);
|
||||||
printlnResource(Constants.RES_CREATE_JOB_SUCCESSFUL, status.name(), job.getPersistenceId());
|
printlnResource(Constants.RES_CREATE_JOB_SUCCESSFUL, status.name(), job.getPersistenceId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
import org.apache.commons.cli.OptionBuilder;
|
import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.sqoop.client.core.ClientError;
|
import org.apache.sqoop.client.core.ClientError;
|
||||||
import org.apache.sqoop.client.core.Constants;
|
import org.apache.sqoop.client.core.Constants;
|
||||||
|
import org.apache.sqoop.client.utils.FormDisplayer;
|
||||||
import org.apache.sqoop.common.SqoopException;
|
import org.apache.sqoop.common.SqoopException;
|
||||||
import org.apache.sqoop.model.MConnection;
|
import org.apache.sqoop.model.MConnection;
|
||||||
import org.apache.sqoop.validation.Status;
|
import org.apache.sqoop.validation.Status;
|
||||||
@ -88,7 +89,7 @@ private void updateConnection(Long connectionId) throws IOException {
|
|||||||
// Try to create
|
// Try to create
|
||||||
status = client.updateConnection(connection);
|
status = client.updateConnection(connection);
|
||||||
} while(!status.canProceed());
|
} while(!status.canProceed());
|
||||||
|
FormDisplayer.displayFormWarning(connection);
|
||||||
printlnResource(Constants.RES_UPDATE_CONN_SUCCESSFUL, status.name());
|
printlnResource(Constants.RES_UPDATE_CONN_SUCCESSFUL, status.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
import org.apache.commons.cli.OptionBuilder;
|
import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.sqoop.client.core.ClientError;
|
import org.apache.sqoop.client.core.ClientError;
|
||||||
import org.apache.sqoop.client.core.Constants;
|
import org.apache.sqoop.client.core.Constants;
|
||||||
|
import org.apache.sqoop.client.utils.FormDisplayer;
|
||||||
import org.apache.sqoop.common.SqoopException;
|
import org.apache.sqoop.common.SqoopException;
|
||||||
import org.apache.sqoop.model.MJob;
|
import org.apache.sqoop.model.MJob;
|
||||||
import org.apache.sqoop.validation.Status;
|
import org.apache.sqoop.validation.Status;
|
||||||
@ -88,7 +89,7 @@ private void updateJob(Long jobId) throws IOException {
|
|||||||
// Try to create
|
// Try to create
|
||||||
status = client.updateJob(job);
|
status = client.updateJob(job);
|
||||||
} while(!status.canProceed());
|
} while(!status.canProceed());
|
||||||
|
FormDisplayer.displayFormWarning(job);
|
||||||
printlnResource(Constants.RES_UPDATE_JOB_SUCCESSFUL, status.name());
|
printlnResource(Constants.RES_UPDATE_JOB_SUCCESSFUL, status.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,17 +18,22 @@
|
|||||||
package org.apache.sqoop.client.utils;
|
package org.apache.sqoop.client.utils;
|
||||||
|
|
||||||
import org.apache.sqoop.client.core.Constants;
|
import org.apache.sqoop.client.core.Constants;
|
||||||
|
import org.apache.sqoop.model.MAccountableEntity;
|
||||||
|
import org.apache.sqoop.model.MConnection;
|
||||||
import org.apache.sqoop.model.MEnumInput;
|
import org.apache.sqoop.model.MEnumInput;
|
||||||
import org.apache.sqoop.model.MForm;
|
import org.apache.sqoop.model.MForm;
|
||||||
import org.apache.sqoop.model.MFramework;
|
import org.apache.sqoop.model.MFramework;
|
||||||
import org.apache.sqoop.model.MInput;
|
import org.apache.sqoop.model.MInput;
|
||||||
import org.apache.sqoop.model.MInputType;
|
import org.apache.sqoop.model.MInputType;
|
||||||
import org.apache.sqoop.model.MIntegerInput;
|
import org.apache.sqoop.model.MIntegerInput;
|
||||||
|
import org.apache.sqoop.model.MJob;
|
||||||
import org.apache.sqoop.model.MJobForms;
|
import org.apache.sqoop.model.MJobForms;
|
||||||
import org.apache.sqoop.model.MMapInput;
|
import org.apache.sqoop.model.MMapInput;
|
||||||
import org.apache.sqoop.model.MStringInput;
|
import org.apache.sqoop.model.MStringInput;
|
||||||
import org.apache.sqoop.utils.StringUtils;
|
import org.apache.sqoop.utils.StringUtils;
|
||||||
|
import org.apache.sqoop.validation.Status;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -120,6 +125,33 @@ public static void displayForms(List<MForm> forms, ResourceBundle bundle) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method prints the warning message of ACCEPTABLE status
|
||||||
|
* @param entity - connection or job instance
|
||||||
|
*/
|
||||||
|
public static void displayFormWarning(MAccountableEntity entity) {
|
||||||
|
List<MForm> formList = new ArrayList<MForm>();
|
||||||
|
boolean showMessage = true;
|
||||||
|
if (entity instanceof MConnection) {
|
||||||
|
MConnection connection = (MConnection) entity;
|
||||||
|
formList.addAll(connection.getConnectorPart().getForms());
|
||||||
|
formList.addAll(connection.getFrameworkPart().getForms());
|
||||||
|
} else if(entity instanceof MJob) {
|
||||||
|
MJob job = (MJob) entity;
|
||||||
|
formList.addAll(job.getConnectorPart().getForms());
|
||||||
|
formList.addAll(job.getFrameworkPart().getForms());
|
||||||
|
}
|
||||||
|
for(MForm form : formList) {
|
||||||
|
if(form.getValidationStatus() == Status.ACCEPTABLE) {
|
||||||
|
if(showMessage) {
|
||||||
|
print("\n@|yellow %s|@\n", resourceString(Constants.RES_FORMDISPLAYER_FORM_WARNING));
|
||||||
|
showMessage = false;
|
||||||
|
}
|
||||||
|
FormFiller.warningMessage(form.getValidationMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void displayForm(MForm form, ResourceBundle bundle) {
|
private static void displayForm(MForm form, ResourceBundle bundle) {
|
||||||
print(" ");
|
print(" ");
|
||||||
println(bundle.getString(form.getLabelKey()));
|
println(bundle.getString(form.getLabelKey()));
|
||||||
|
@ -187,3 +187,5 @@ formdisplayer.size = Size
|
|||||||
formdisplayer.possible_values = Possible values
|
formdisplayer.possible_values = Possible values
|
||||||
formdisplayer.unsupported_datatype = Unsupported data type
|
formdisplayer.unsupported_datatype = Unsupported data type
|
||||||
formdisplayer.input_sensitive = This input is sensitive
|
formdisplayer.input_sensitive = This input is sensitive
|
||||||
|
|
||||||
|
formdisplayer.warning_message = There were warnings while create or update, but saved successfully.
|
Loading…
Reference in New Issue
Block a user