My code is below. This is cascading code.
And it has 8 jobs. I don't know how to configure every job.
Code below configure 8 jobs togerher.
But what i want to do is let last job one reduce.
I want to ask how to recoginse this 8 jobs, and how to configure them seperatly?
thanks.
private static void Demo(String[] args) {
/* Tap sourceTap = new Hfs(new TextLine(), "D:/test/file");
Tap finalResultTap = new Hfs(new TextLine(), "D:/test/result", true);
*/
Tap sourceTap = new Hfs(new TextLine(), args[0], SinkMode.KEEP);
Tap finalResultTap = new Hfs(new TextLine(), args[1], SinkMode.REPLACE);
Tap trap = new Hfs(new TextLine(), args[2], SinkMode.REPLACE);
Pipe sourcePipe = new Pipe("sourcePipe");
sourcePipe = getFilterPipe(sourcePipe);
Pipe vvResultPipe = new Pipe("vvResultPipe", sourcePipe);
vvResultPipe = getVVResultPipe(sourcePipe);
Pipe clickResultPipe = new Pipe("clickResultPipe", sourcePipe);
clickResultPipe = getClickResultPipe(clickResultPipe);
Pipe stClickResultPipe = new Pipe("stClickResultPipe", sourcePipe);
stClickResultPipe = getStClickResultPipe(sourcePipe);
//连接3个pipe的结果
Pipe resultPipe = new Pipe("resultPipe");
resultPipe = new CoGroup(vvResultPipe, new Fields("vid"), clickResultPipe, new Fields("referVid"),
new Fields("vid", "totalVV", "referVid", "totalClick"), new LeftJoin());
resultPipe = new CoGroup(resultPipe, new Fields("vid"), stClickResultPipe, new Fields("referVid"),
new Fields("vid", "totalVV", "referVid", "totalClick", "referVid2", "st1","st2","st3", "st4","st6", "st8"), new LeftJoin());
resultPipe = new Each(resultPipe, new Fields("vid", "totalVV", "totalClick", "st1","st2","st3", "st4","st6", "st8"),
new Identity(Fields.ARGS));
Fields sortClickFields = new Fields("totalVV");
resultPipe = new GroupBy(resultPipe, Fields.NONE, sortClickFields );
sortClickFields.setComparators(Collections.reverseOrder());
/* Limit limit = new Limit(200);
resultPipe = new Each(resultPipe, limit);
*/
JobConf conf = new JobConf();
conf.setJarByClass(Main.class);
//Properties properties = new Properties();
Properties properties = AppProps.appProps().buildProperties(conf);
properties.setProperty("user.group", "d_sdo_data");
properties.setProperty("mapred.job.queue.name", "cug_d_sdo_data");
properties.setProperty("mapred.fairscheduler.pool", "cug_d_sdo_data");
properties.setProperty("cascading.tmp.dir", "/home/hdfs/cluster-data/tmp/mapred/staging/recommend_user/tmp");
properties.setProperty("mapreduce.job.complete.cancel.delegation.tokens", "false");
properties.setProperty("mapred.reduce.tasks", "30");
properties.setProperty("mapred.map.tasks", "200");
//AppProps.setApplicationJarClass(properties, Main.class);
FlowConnector flowConnector = new HadoopFlowConnector(properties);
FlowDef flowDef = FlowDef.flowDef()
.setName( "tfidf" )
.addSource( sourcePipe, sourceTap )
.addTailSink( resultPipe, finalResultTap )
.addTrap( "assertions", trap );
Flow flow = flowConnector.connect(flowDef);
flow.complete();
}
This question is three years old, but I ran across it while looking for this solution. Here's what I finally ended up with:
pipe.getStepConfigDef().setProperty("mapreduce.job.reduces", "1");
This goes after you've defined the step you want to configure.
Note that this is for Hadoop 2.6.4 - if you're using mapred.reduce.tasks property instead. See here:
https://hadoop.apache.org/docs/r2.6.4/hadoop-project-dist/hadoop-common/DeprecatedProperties.html
Related
Approach 1:
final ClientCredentialProvider clientCredentialProvider = new ClientCredentialProvider(
client_id,
ImmutableList.of("https://graph.microsoft.com/.default"),
secret,
tenant,
NationalCloud.Global
);
IGraphServiceClient graphClient = com.microsoft.graph.requests.extensions.GraphServiceClient
.builder()
.authenticationProvider(clientCredentialProvider)
.buildClient();
Approach 2:
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId(client_id)
.clientSecret(secret)
.tenantId(tenant)
.build();
authProvider = new TokenCredentialAuthProvider(clientSecretCredential);
// Build a Graph client
GraphServiceClient<Request> graphClient = GraphServiceClient.builder()
.authenticationProvider(authProvider)
.buildClient();
Left side table is distorted while comparing two HTML table data using daisydiff.jar.
I need your support to fix this issue. Thanks in advance
Using below code
StringWriter finalResult = new StringWriter();
SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); TransformerHandler result = tf.newTransformerHandler();
result.getTransformer().setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
result.getTransformer().setOutputProperty(OutputKeys.INDENT, "no");
result.getTransformer().setOutputProperty(OutputKeys.METHOD, "html");
result.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
result.setResult(new StreamResult(finalResult));
ContentHandler postProcess = result;
Locale locale = Locale.getDefault();
String prefix = "diff";
NekoHtmlParser cleaner = new NekoHtmlParser();
InputSource oldSource = new InputSource (new String reader(html1));
InputSource newSource = new InputSource (new String reader(html2));
DomTreeBuilder oldHandler = new DomTreeBuilder ();
cleaner.parse(oldSource, oldHandler);
TextNodeComparator leftComparator = new TextNodeComparator (oldHandler, locale);
DomTreeBuilder newHandler = new DomTreeBuilder ();
cleaner.parse(newSource, newHandler);
TextNodeComparator rightComparator = new TextNodeComparator (newHandler, locale);
HtmlSaxDiffOutput output = new HtmlSaxDiffOutput (postProcess, prefix);
HTMLDiffer differ = new HTMLDiffer(output);
differ.diff(leftComparator, rightComparator);
With the new version of Primefaces (7.0) the jqplot-charts got replaced by ChartJS Charts. Now I want the Y-Axis of my chart to be longer. With the old charts this was easily possible in Java but now I don't know how to do it. If it isn't possible in Java is there an alternative way to change the Y-Axis of an existing chart?
It all right in the showcase in the 2nd example for Cartesian Line Model.
https://www.primefaces.org/showcase/ui/chartjs/line.xhtml
public void createCartesianLinerModel() {
cartesianLinerModel = new LineChartModel();
ChartData data = new ChartData();
LineChartDataSet dataSet = new LineChartDataSet();
List<Number> values = new ArrayList<>();
values.add(20);
values.add(50);
values.add(100);
values.add(75);
values.add(25);
values.add(0);
dataSet.setData(values);
dataSet.setLabel("Left Dataset");
dataSet.setYaxisID("left-y-axis");
LineChartDataSet dataSet2 = new LineChartDataSet();
List<Number> values2 = new ArrayList<>();
values2.add(0.1);
values2.add(0.5);
values2.add(1.0);
values2.add(2.0);
values2.add(1.5);
values2.add(0);
dataSet2.setData(values2);
dataSet2.setLabel("Right Dataset");
dataSet2.setYaxisID("right-y-axis");
data.addChartDataSet(dataSet);
data.addChartDataSet(dataSet2);
List<String> labels = new ArrayList<>();
labels.add("Jan");
labels.add("Feb");
labels.add("Mar");
labels.add("Apr");
labels.add("May");
labels.add("Jun");
data.setLabels(labels);
cartesianLinerModel.setData(data);
//Options
LineChartOptions options = new LineChartOptions();
CartesianScales cScales = new CartesianScales();
CartesianLinearAxes linearAxes = new CartesianLinearAxes();
linearAxes.setId("left-y-axis");
linearAxes.setPosition("left");
CartesianLinearAxes linearAxes2 = new CartesianLinearAxes();
linearAxes2.setId("right-y-axis");
linearAxes2.setPosition("right");
cScales.addYAxesData(linearAxes);
cScales.addYAxesData(linearAxes2);
options.setScales(cScales);
Title title = new Title();
title.setDisplay(true);
title.setText("Cartesian Linear Chart");
options.setTitle(title);
cartesianLinerModel.setOptions(options);
}
I'm using geotools-18.5, with JavaFx in Inteliji IDE.
When I want to create PointSymbolizer from a svg or png image.
StyleBuilder builder = new StyleBuilder();
ExternalGraphic extGraphic = builder.createExternalGraphic("file:/home/cuongnv/test.svg", "svg");
I build code OK, but when run, I received warning:
WARNING: Can't load a service for category "ExternalGraphicFactory".
Provider org.geotools.renderer.style.ImageGraphicFactory could not be
instantiated.
Can someone help me ?
Here is full code:
private Style createStyleBuilder(){
StyleBuilder builder = new StyleBuilder();
FilterFactory2 ff = builder.getFilterFactory();
// RULE 1
// first rule to draw cities
// define a point symbolizer representing a city
Graphic city = builder.createGraphic();
city.setSize(ff.literal(50));
ExternalGraphic extGraphic = builder.createExternalGraphic("file:/home/cuongnv/Javafx/GeoTool/geotools_fx_tutorial-master/geotools-fx/src/main/resources/images/console.svg", "svg"); // svg
city.addExternalGraphic(extGraphic);
PointSymbolizer pointSymbolizer = builder.createPointSymbolizer(city);
Rule rule1 = builder.createRule(pointSymbolizer);
rule1.setName("rule1");
rule1.getDescription().setTitle("City");
rule1.getDescription().setAbstract("Rule for drawing cities");
Rule rules[] = new Rule[] {rule1};
FeatureTypeStyle featureTypeStyle = builder.createFeatureTypeStyle("Feature", rules);
Style style = builder.createStyle();
style.setName("style");
style.getDescription().setTitle("User Style");
style.getDescription().setAbstract("Definition of Style");
style.featureTypeStyles().add(featureTypeStyle);
return style;
}
TYPE = DataUtilities.createType(
"Dataset",
"geometry:Geometry:srid=4326"
+ ","
+ "name:String,"
+ "id:String"
);
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE);
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
com.vividsolutions.jts.geom.Point point = geometryFactory.createPoint(new Coordinate(x,y));
featureBuilder.add(point);
SimpleFeature feature = featureBuilder.buildFeature(null);
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection("internal", TYPE);
featureCollection.add(feature);
Style style = createStyleBuilder();
Layer layer = new FeatureLayer(featureCollection, style);
layer.setTitle("New Point");
mapContent.layers().add(layer);
You have set the image mime type incorrectly, it should be:
ExternalGraphic extGraphic = builder.createExternalGraphic("file:/stuff/ian/geoserver/data/styles/burg02.svg", "image/svg"); // svg
and all will work.
EDIT
If you are still having issues then try adding this code to the end of the createStyle module and look at the generated SVG, possibly in GeoServer to test it out.
SLDTransformer styleTransform = new SLDTransformer();
StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
UserLayer layer = sf.createUserLayer();
layer.setLayerFeatureConstraints(new FeatureTypeConstraint[] {null});
sld.addStyledLayer(layer);
layer.addUserStyle(style);
try {
String xml = styleTransform.transform(sld);
System.out.println(xml);
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I need the following if statement inside the adopt code, but its not valid if it is there. is there some way I can do the same some other way?
var ele = new Element('li').adopt(
new Element('span.title', {text:row.title}),
new Element('span.subtitle').adopt(
// Need this to work, but its invalid where it is atm
if(row.subtitle = 1)
{
new Element('img', {src:'images/subTitle.png'})
}
),
new Element('span.bold', {text:row.bold}),
);
ele.iject(...
I'm not very familiar with MooTools, but I don't see why this wouldn't work:
var subtitle = new Element('span.subtitle');
if (row.subtitle == 1) subtitle.adopt(new Element('img', {src:'images/subTitle.png'}));
var ele = new Element('li').adopt(
new Element('span.title', {text:row.title}),
subtitle,
new Element('span.bold', {text:row.bold}),
);
Immediate if FTW:
var ele = new Element('li').adopt(
new Element('span.title', {text:row.title}),
new Element('span.subtitle').adopt(
(row.subtitle == 1) ? new Element('img', {src:'images/subTitle.png'}) : null
),
new Element('span.bold', {text:row.bold}),
);