本文整理汇总了Java中com.cloudera.sqoop.util.StoredAsProperty类的典型用法代码示例。如果您正苦于以下问题:Java StoredAsProperty类的具体用法?Java StoredAsProperty怎么用?Java StoredAsProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StoredAsProperty类属于com.cloudera.sqoop.util包,在下文中一共展示了StoredAsProperty类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeProperties
import com.cloudera.sqoop.util.StoredAsProperty; //导入依赖的package包/类
/**
* Return a Properties instance that encapsulates all the "sticky"
* state of this SqoopOptions that should be written to a metastore
* to restore the job later.
*/
public Properties writeProperties() {
Properties props = new Properties();
try {
Field [] fields = SqoopOptions.class.getDeclaredFields();
for (Field f : fields) {
if (f.isAnnotationPresent(StoredAsProperty.class)) {
Class typ = f.getType();
StoredAsProperty storedAs = f.getAnnotation(StoredAsProperty.class);
String propName = storedAs.value();
if (typ.equals(int.class)) {
putProperty(props, propName, Integer.toString(f.getInt(this)));
} else if (typ.equals(boolean.class)) {
putProperty(props, propName, Boolean.toString(f.getBoolean(this)));
} else if (typ.equals(long.class)) {
putProperty(props, propName, Long.toString(f.getLong(this)));
} else if (typ.equals(String.class)) {
putProperty(props, propName, (String) f.get(this));
} else if (typ.equals(Integer.class)) {
putProperty(
props,
propName,
f.get(this) == null ? "null" : f.get(this).toString());
} else if (typ.isEnum()) {
putProperty(props, propName, f.get(this).toString());
} else if (typ.equals(Map.class)) {
putProperty(
props,
propName,
SqoopJsonUtil.getJsonStringforMap((Map) f.get(this)));
} else {
throw new RuntimeException("Could not set property "
+ propName + " for type: " + typ);
}
}
}
} catch (IllegalAccessException iae) {
throw new RuntimeException("Illegal access to field in property setter",
iae);
}
writePasswordProperty(props);
putProperty(props, "db.column.list", arrayToList(this.columns));
setDelimiterProperties(props, "codegen.input.delimiters",
this.inputDelimiters);
setDelimiterProperties(props, "codegen.output.delimiters",
this.outputDelimiters);
setArgArrayProperties(props, "tool.arguments", this.extraArgs);
setPropertiesAsNestedProperties(props,
"db.connect.params", this.connectionParams);
setPropertiesAsNestedProperties(props,
"map.column.hive", this.mapColumnHive);
setPropertiesAsNestedProperties(props,
"map.column.java", this.mapColumnJava);
setPropertiesAsNestedProperties(props,
"map.column.odps", this.mapColumnOdps);
return props;
}
示例2: writeProperties
import com.cloudera.sqoop.util.StoredAsProperty; //导入依赖的package包/类
/**
* Return a Properties instance that encapsulates all the "sticky"
* state of this SqoopOptions that should be written to a metastore
* to restore the job later.
*/
public Properties writeProperties() {
Properties props = new Properties();
try {
Field [] fields = SqoopOptions.class.getDeclaredFields();
for (Field f : fields) {
if (f.isAnnotationPresent(StoredAsProperty.class)) {
Class typ = f.getType();
StoredAsProperty storedAs = f.getAnnotation(StoredAsProperty.class);
String propName = storedAs.value();
if (typ.equals(int.class)) {
putProperty(props, propName, Integer.toString(f.getInt(this)));
} else if (typ.equals(boolean.class)) {
putProperty(props, propName, Boolean.toString(f.getBoolean(this)));
} else if (typ.equals(long.class)) {
putProperty(props, propName, Long.toString(f.getLong(this)));
} else if (typ.equals(String.class)) {
putProperty(props, propName, (String) f.get(this));
} else if (typ.equals(Integer.class)) {
putProperty(
props,
propName,
f.get(this) == null ? "null" : f.get(this).toString());
} else if (typ.isEnum()) {
putProperty(props, propName, f.get(this).toString());
} else {
throw new RuntimeException("Could not set property "
+ propName + " for type: " + typ);
}
}
}
} catch (IllegalAccessException iae) {
throw new RuntimeException("Illegal access to field in property setter",
iae);
}
writePasswordProperty(props);
putProperty(props, "db.column.list", arrayToList(this.columns));
setDelimiterProperties(props, "codegen.input.delimiters",
this.inputDelimiters);
setDelimiterProperties(props, "codegen.output.delimiters",
this.outputDelimiters);
setArgArrayProperties(props, "tool.arguments", this.extraArgs);
setPropertiesAsNestedProperties(props,
"db.connect.params", this.connectionParams);
setPropertiesAsNestedProperties(props,
"map.column.hive", this.mapColumnHive);
setPropertiesAsNestedProperties(props,
"map.column.java", this.mapColumnJava);
return props;
}
示例3: writeProperties
import com.cloudera.sqoop.util.StoredAsProperty; //导入依赖的package包/类
/**
* Return a Properties instance that encapsulates all the "sticky"
* state of this SqoopOptions that should be written to a metastore
* to restore the job later.
*/
public Properties writeProperties() {
Properties props = new Properties();
try {
Field [] fields = SqoopOptions.class.getDeclaredFields();
for (Field f : fields) {
if (f.isAnnotationPresent(StoredAsProperty.class)) {
Class typ = f.getType();
StoredAsProperty storedAs = f.getAnnotation(StoredAsProperty.class);
String propName = storedAs.value();
if (typ.equals(int.class)) {
putProperty(props, propName, Integer.toString(f.getInt(this)));
} else if (typ.equals(boolean.class)) {
putProperty(props, propName, Boolean.toString(f.getBoolean(this)));
} else if (typ.equals(long.class)) {
putProperty(props, propName, Long.toString(f.getLong(this)));
} else if (typ.equals(String.class)) {
putProperty(props, propName, (String) f.get(this));
} else if (typ.equals(Integer.class)) {
putProperty(
props,
propName,
f.get(this) == null ? "null" : f.get(this).toString());
} else if (typ.isEnum()) {
putProperty(props, propName, f.get(this).toString());
} else {
throw new RuntimeException("Could not set property "
+ propName + " for type: " + typ);
}
}
}
} catch (IllegalAccessException iae) {
throw new RuntimeException("Illegal access to field in property setter",
iae);
}
if (this.getConf().getBoolean(
METASTORE_PASSWORD_KEY, METASTORE_PASSWORD_DEFAULT)) {
// If the user specifies, we may store the password in the metastore.
putProperty(props, "db.password", this.password);
putProperty(props, "db.require.password", "false");
} else if (this.password != null) {
// Otherwise, if the user has set a password, we just record
// a flag stating that the password will need to be reentered.
putProperty(props, "db.require.password", "true");
} else {
// No password saved or required.
putProperty(props, "db.require.password", "false");
}
putProperty(props, "db.column.list", arrayToList(this.columns));
setDelimiterProperties(props, "codegen.input.delimiters",
this.inputDelimiters);
setDelimiterProperties(props, "codegen.output.delimiters",
this.outputDelimiters);
setArgArrayProperties(props, "tool.arguments", this.extraArgs);
setPropertiesAsNestedProperties(props,
"db.connect.params", this.connectionParams);
setPropertiesAsNestedProperties(props,
"map.column.hive", this.mapColumnHive);
setPropertiesAsNestedProperties(props,
"map.column.java", this.mapColumnJava);
return props;
}