• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TestBaseUtils类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.apache.flink.test.util.TestBaseUtils的典型用法代码示例。如果您正苦于以下问题:Java TestBaseUtils类的具体用法?Java TestBaseUtils怎么用?Java TestBaseUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TestBaseUtils类属于org.apache.flink.test.util包,在下文中一共展示了TestBaseUtils类的40个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testTableSourceFullScan

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testTableSourceFullScan() throws Exception {

	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(4);
	BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, new TableConfig());
	HBaseTableSource hbaseTable = new HBaseTableSource(getConf(), TEST_TABLE);
	hbaseTable.addColumn(FAMILY1, F1COL1, Integer.class);
	hbaseTable.addColumn(FAMILY2, F2COL1, String.class);
	hbaseTable.addColumn(FAMILY2, F2COL2, Long.class);
	hbaseTable.addColumn(FAMILY3, F3COL1, Double.class);
	hbaseTable.addColumn(FAMILY3, F3COL2, Boolean.class);
	hbaseTable.addColumn(FAMILY3, F3COL3, String.class);
	tableEnv.registerTableSource("hTable", hbaseTable);

	Table result = tableEnv.sqlQuery(
		"SELECT " +
			"  h.family1.col1, " +
			"  h.family2.col1, " +
			"  h.family2.col2, " +
			"  h.family3.col1, " +
			"  h.family3.col2, " +
			"  h.family3.col3 " +
			"FROM hTable AS h"
	);
	DataSet<Row> resultSet = tableEnv.toDataSet(result, Row.class);
	List<Row> results = resultSet.collect();

	String expected =
		"10,Hello-1,100,1.01,false,Welt-1\n" +
		"20,Hello-2,200,2.02,true,Welt-2\n" +
		"30,Hello-3,300,3.03,false,Welt-3\n" +
		"40,null,400,4.04,true,Welt-4\n" +
		"50,Hello-5,500,5.05,false,Welt-5\n" +
		"60,Hello-6,600,6.06,true,Welt-6\n" +
		"70,Hello-7,700,7.07,false,Welt-7\n" +
		"80,null,800,8.08,true,Welt-8\n";

	TestBaseUtils.compareResultAsText(results, expected);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:41,
代码来源:HBaseConnectorITCase.java

示例2: getNumberOfTaskManagers

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void getNumberOfTaskManagers() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + port + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode response = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) response.get("taskmanagers");

		assertNotNull(taskManagers);
		assertEquals(cluster.numTaskManagers(), taskManagers.size());
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:18,
代码来源:WebFrontendITCase.java

示例3: setup

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Before
public void setup() throws Exception {

	// Flink configuration
	final Configuration config = new Configuration();

	config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, 1);
	config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, DEFAULT_PARALLELISM);

	final File checkpointDir = tempFolder.newFolder("checkpoints").getAbsoluteFile();
	final File savepointDir = tempFolder.newFolder("savepoints").getAbsoluteFile();

	if (!checkpointDir.exists() || !savepointDir.exists()) {
		throw new Exception("Test setup failed: failed to create (temporary) directories.");
	}

	LOG.info("Created temporary checkpoint directory: " + checkpointDir + ".");
	LOG.info("Created savepoint directory: " + savepointDir + ".");

	config.setString(CheckpointingOptions.STATE_BACKEND, "memory");
	config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir.toURI().toString());
	config.setInteger(CheckpointingOptions.FS_SMALL_FILE_THRESHOLD, 0);
	config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir.toURI().toString());

	cluster = TestBaseUtils.startCluster(config, false);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:27,
代码来源:SavepointMigrationTestBase.java

示例4: after

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@After
public void after() throws Exception {
	TestBaseUtils.compareResultsByLinesInMemory(expectedTopSongs, topSongsResultPath);

	ArrayList<String> list = new ArrayList<>();
	TestBaseUtils.readAllResultLines(list, communitiesResultPath, new String[]{}, false);

	String[] result = list.toArray(new String[list.size()]);
	Arrays.sort(result);

	// check that user_1 and user_2 are in the same community
	Assert.assertEquals("users 1 and 2 are not in the same community",
			result[0].substring(7), result[1].substring(7));

	// check that user_3, user_4 and user_5 are in the same community
	Assert.assertEquals("users 3 and 4 are not in the same community",
			result[2].substring(7), result[3].substring(7));
	Assert.assertEquals("users 4 and 5 are not in the same community",
			result[3].substring(7), result[4].substring(7));
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:21,
代码来源:MusicProfilesITCase.java

示例5: testTranslateGraphIds

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testTranslateGraphIds() throws Exception {
	Graph<StringValue, LongValue, LongValue> stringIdGraph = graph
		.translateGraphIds(new LongValueToStringValue());

	for (Vertex<StringValue, LongValue> vertex : stringIdGraph.getVertices().collect()) {
		assertEquals(StringValue.class, vertex.f0.getClass());
		assertEquals(LongValue.class, vertex.f1.getClass());
	}

	for (Edge<StringValue, LongValue> edge : stringIdGraph.getEdges().collect()) {
		assertEquals(StringValue.class, edge.f0.getClass());
		assertEquals(StringValue.class, edge.f1.getClass());
		assertEquals(LongValue.class, edge.f2.getClass());
	}

	TestBaseUtils.compareResultAsText(stringIdGraph.getVertices().collect(), expectedVertexResult);
	TestBaseUtils.compareResultAsText(stringIdGraph.getEdges().collect(), expectedEdgeResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:20,
代码来源:TranslateTest.java

示例6: testWithDirectedSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithDirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> outDegree = directedSimpleGraph
		.run(new VertexOutDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,2)\n" +
		"(1,0)\n" +
		"(2,2)\n" +
		"(3,2)\n" +
		"(4,0)\n" +
		"(5,1)";

	TestBaseUtils.compareResultAsText(outDegree.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:VertexOutDegreeTest.java

示例7: testWithUndirectedSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithUndirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> outDegree = undirectedSimpleGraph
		.run(new VertexOutDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,2)\n" +
		"(1,3)\n" +
		"(2,3)\n" +
		"(3,4)\n" +
		"(4,1)\n" +
		"(5,1)";

	TestBaseUtils.compareResultAsText(outDegree.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:VertexOutDegreeTest.java

示例8: testWithEmptyGraphWithVertices

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, LongValue>> outDegreeWithoutZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexOutDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, outDegreeWithoutZeroDegreeVertices.collect().size());

	DataSet<Vertex<LongValue, LongValue>> outDegreeWithZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexOutDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,0)\n" +
		"(1,0)\n" +
		"(2,0)";

	TestBaseUtils.compareResultAsText(outDegreeWithZeroDegreeVertices.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:20,
代码来源:VertexOutDegreeTest.java

示例9: testWithSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),(2,2,0),(3,0,3)))\n" +
		"(0,2,((null),(2,2,0),(3,2,1)))\n" +
		"(2,1,((null),(3,2,1),(3,0,3)))\n" +
		"(2,3,((null),(3,2,1),(4,2,2)))\n" +
		"(3,1,((null),(4,2,2),(3,0,3)))\n" +
		"(3,4,((null),(4,2,2),(1,0,1)))\n" +
		"(5,3,((null),(1,1,0),(4,2,2)))";

	DataSet<Edge<IntValue, Tuple3<NullValue, Degrees, Degrees>>> degreesPair = directedSimpleGraph
		.run(new EdgeDegreesPair<>());

	TestBaseUtils.compareResultAsText(degreesPair.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:EdgeDegreesPairTest.java

示例10: testWithSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),(2,2,0)))\n" +
		"(0,2,((null),(2,2,0)))\n" +
		"(2,1,((null),(3,2,1)))\n" +
		"(2,3,((null),(3,2,1)))\n" +
		"(3,1,((null),(4,2,2)))\n" +
		"(3,4,((null),(4,2,2)))\n" +
		"(5,3,((null),(1,1,0)))";

	DataSet<Edge<IntValue, Tuple2<NullValue, Degrees>>> sourceDegrees = directedSimpleGraph
			.run(new EdgeSourceDegrees<>());

	TestBaseUtils.compareResultAsText(sourceDegrees.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:EdgeSourceDegreesTest.java

示例11: testWithDirectedSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithDirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> inDegree = directedSimpleGraph
		.run(new VertexInDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,0)\n" +
		"(1,3)\n" +
		"(2,1)\n" +
		"(3,2)\n" +
		"(4,1)\n" +
		"(5,0)";

	TestBaseUtils.compareResultAsText(inDegree.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:VertexInDegreeTest.java

示例12: testWithUndirectedSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithUndirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> inDegree = undirectedSimpleGraph
		.run(new VertexInDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,2)\n" +
		"(1,3)\n" +
		"(2,3)\n" +
		"(3,4)\n" +
		"(4,1)\n" +
		"(5,1)";

	TestBaseUtils.compareResultAsText(inDegree.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:VertexInDegreeTest.java

示例13: testWithEmptyGraphWithVertices

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, LongValue>> inDegreeWithoutZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexInDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, inDegreeWithoutZeroDegreeVertices.collect().size());

	DataSet<Vertex<LongValue, LongValue>> inDegreeWithZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexInDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,0)\n" +
		"(1,0)\n" +
		"(2,0)";

	TestBaseUtils.compareResultAsText(inDegreeWithZeroDegreeVertices.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:20,
代码来源:VertexInDegreeTest.java

示例14: testWithEmptyGraphWithVertices

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, Degrees>> degreesWithoutZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexDegrees<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, degreesWithoutZeroDegreeVertices.collect().size());

	DataSet<Vertex<LongValue, Degrees>> degreesWithZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexDegrees<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,(0,0,0))\n" +
		"(1,(0,0,0))\n" +
		"(2,(0,0,0))";

	TestBaseUtils.compareResultAsText(degreesWithZeroDegreeVertices.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:20,
代码来源:VertexDegreesTest.java

示例15: testWithSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),(3,0,3)))\n" +
		"(0,2,((null),(3,2,1)))\n" +
		"(2,1,((null),(3,0,3)))\n" +
		"(2,3,((null),(4,2,2)))\n" +
		"(3,1,((null),(3,0,3)))\n" +
		"(3,4,((null),(1,0,1)))\n" +
		"(5,3,((null),(4,2,2)))";

	DataSet<Edge<IntValue, Tuple2<NullValue, Degrees>>> targetDegrees = directedSimpleGraph
			.run(new EdgeTargetDegrees<>());

	TestBaseUtils.compareResultAsText(targetDegrees.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:EdgeTargetDegreesTest.java

示例16: testWithSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,2)\n" +
		"(1,3)\n" +
		"(2,3)\n" +
		"(3,4)\n" +
		"(4,1)\n" +
		"(5,1)";

	DataSet<Vertex<IntValue, LongValue>> degreeOnSourceId = undirectedSimpleGraph
		.run(new VertexDegree<IntValue, NullValue, NullValue>()
			.setReduceOnTargetId(false));

	TestBaseUtils.compareResultAsText(degreeOnSourceId.collect(), expectedResult);

	DataSet<Vertex<IntValue, LongValue>> degreeOnTargetId = undirectedSimpleGraph
		.run(new VertexDegree<IntValue, NullValue, NullValue>()
			.setReduceOnTargetId(true));

	TestBaseUtils.compareResultAsText(degreeOnTargetId.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:23,
代码来源:VertexDegreeTest.java

示例17: testWithEmptyGraphWithVertices

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, LongValue>> degree;

	degree = emptyGraphWithVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, degree.collect().size());

	degree = emptyGraphWithVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,0)\n" +
		"(1,0)\n" +
		"(2,0)";

	TestBaseUtils.compareResultAsText(degree.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:22,
代码来源:VertexDegreeTest.java

示例18: testWithSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSimpleGraph() throws Exception {
	Graph<IntValue, NullValue, NullValue> graph = undirectedSimpleGraph
		.run(new MaximumDegree<>(3));

	String expectedVerticesResult =
		"(0,(null))\n" +
		"(1,(null))\n" +
		"(2,(null))\n" +
		"(4,(null))\n" +
		"(5,(null))";

	TestBaseUtils.compareResultAsText(graph.getVertices().collect(), expectedVerticesResult);

	String expectedEdgesResult =
		"(0,1,(null))\n" +
		"(0,2,(null))\n" +
		"(1,0,(null))\n" +
		"(1,2,(null))\n" +
		"(2,0,(null))\n" +
		"(2,1,(null))";

	TestBaseUtils.compareResultAsText(graph.getEdges().collect(), expectedEdgesResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:25,
代码来源:MaximumDegreeTest.java

示例19: testSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testSimpleGraph() throws Exception {
	DataSet<Result<IntValue>> ji = undirectedSimpleGraph
		.run(new JaccardIndex<>());

	String expectedResult =
		"(0,1,1,4)\n" +
		"(0,2,1,4)\n" +
		"(0,3,2,4)\n" +
		"(1,2,2,4)\n" +
		"(1,3,1,6)\n" +
		"(1,4,1,3)\n" +
		"(1,5,1,3)\n" +
		"(2,3,1,6)\n" +
		"(2,4,1,3)\n" +
		"(2,5,1,3)\n" +
		"(4,5,1,1)\n";

	TestBaseUtils.compareResultAsText(ji.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:21,
代码来源:JaccardIndexTest.java

示例20: testWithSimpleGraphWithMaximumScore

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSimpleGraphWithMaximumScore() throws Exception {
	DataSet<Result<IntValue>> ji = undirectedSimpleGraph
		.run(new JaccardIndex<IntValue, NullValue, NullValue>()
			.setMaximumScore(1, 2));

	String expectedResult =
		"(0,1,1,4)\n" +
		"(0,2,1,4)\n" +
		"(0,3,2,4)\n" +
		"(1,2,2,4)\n" +
		"(1,3,1,6)\n" +
		"(1,4,1,3)\n" +
		"(1,5,1,3)\n" +
		"(2,3,1,6)\n" +
		"(2,4,1,3)\n" +
		"(2,5,1,3)\n";

	TestBaseUtils.compareResultAsText(ji.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:21,
代码来源:JaccardIndexTest.java

示例21: testWithSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSimpleGraph() throws Exception {
	DataSet<Result<IntValue>> aa = undirectedSimpleGraph
		.run(new AdamicAdar<>());

	String expectedResult =
		"(0,1," + ilog[2] + ")\n" +
		"(0,2," + ilog[1] + ")\n" +
		"(0,3," + (ilog[1] + ilog[2]) + ")\n" +
		"(1,2," + (ilog[0] + ilog[3]) + ")\n" +
		"(1,3," + ilog[2] + ")\n" +
		"(1,4," + ilog[3] + ")\n" +
		"(1,5," + ilog[3] + ")\n" +
		"(2,3," + ilog[1] + ")\n" +
		"(2,4," + ilog[3] + ")\n" +
		"(2,5," + ilog[3] + ")\n" +
		"(4,5," + ilog[3] + ")";

	TestBaseUtils.compareResultAsText(aa.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:21,
代码来源:AdamicAdarTest.java

示例22: testWithSimpleGraphWithMinimumScore

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSimpleGraphWithMinimumScore() throws Exception {
	DataSet<Result<IntValue>> aa = undirectedSimpleGraph
		.run(new AdamicAdar<IntValue, NullValue, NullValue>()
			.setMinimumScore(0.75f));

	String expectedResult =
		"(0,1," + ilog[2] + ")\n" +
		"(0,2," + ilog[1] + ")\n" +
		"(0,3," + (ilog[1] + ilog[2]) + ")\n" +
		"(1,2," + (ilog[0] + ilog[3]) + ")\n" +
		"(1,3," + ilog[2] + ")\n" +
		"(2,3," + ilog[1] + ")";

	TestBaseUtils.compareResultAsText(aa.collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:AdamicAdarTest.java

示例23: testWithSimpleGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSimpleGraph() throws Exception {
	Graph<IntValue, Long, Double> result = undirectedSimpleGraph
		.mapVertices(v -> (long) v.getId().getValue(),
			new TypeHint<Vertex<IntValue, Long>>(){}.getTypeInfo())
		.mapEdges(e -> (double) e.getTarget().getValue() + e.getSource().getValue(),
			new TypeHint<Edge<IntValue, Double>>(){}.getTypeInfo())
		.run(new CommunityDetection<>(10, 0.5));

	String expectedResult =
		"(0,3)\n" +
		"(1,5)\n" +
		"(2,5)\n" +
		"(3,3)\n" +
		"(4,5)\n" +
		"(5,5)\n";

	TestBaseUtils.compareResultAsText(result.getVertices().collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:20,
代码来源:CommunityDetectionTest.java

示例24: testWithSingletonEdgeGraph

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testWithSingletonEdgeGraph() throws Exception {
	Graph<LongValue, Long, Double> result = new SingletonEdgeGraph(env, 1)
		.generate()
		.mapVertices(v -> v.getId().getValue(),
			new TypeHint<Vertex<LongValue, Long>>(){}.getTypeInfo())
		.mapEdges(e -> 1.0,
			new TypeHint<Edge<LongValue, Double>>(){}.getTypeInfo())
		.run(new CommunityDetection<>(10, 0.5));

	String expectedResult =
		"(0,0)\n" +
		"(1,1)\n";

	TestBaseUtils.compareResultAsText(result.getVertices().collect(), expectedResult);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:CommunityDetectionTest.java

示例25: getNumberOfTaskManagers

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void getNumberOfTaskManagers() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + port + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode response = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) response.get("taskmanagers");

		assertNotNull(taskManagers);
		assertEquals(cluster.numTaskManagers(), taskManagers.size());
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:WebFrontendITCase.java

示例26: getTaskmanagers

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void getTaskmanagers() throws Exception {
	String json = TestBaseUtils.getFromHTTP("http://localhost:" + port + "/taskmanagers/");

	ObjectMapper mapper = new ObjectMapper();
	JsonNode parsed = mapper.readTree(json);
	ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");

	assertNotNull(taskManagers);
	assertEquals(cluster.numTaskManagers(), taskManagers.size());

	JsonNode taskManager = taskManagers.get(0);
	assertNotNull(taskManager);
	assertEquals(NUM_SLOTS, taskManager.get("slotsNumber").asInt());
	assertTrue(taskManager.get("freeSlots").asInt() <= NUM_SLOTS);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:WebFrontendITCase.java

示例27: getTaskManagerLogAndStdoutFiles

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void getTaskManagerLogAndStdoutFiles() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + port + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode parsed = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");
		JsonNode taskManager = taskManagers.get(0);
		String id = taskManager.get("id").asText();

		WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(cluster.configuration());

		//we check for job manager log files, since no separate taskmanager logs exist
		FileUtils.writeStringToFile(logFiles.logFile, "job manager log");
		String logs = TestBaseUtils.getFromHTTP("http://localhost:" + port + "/taskmanagers/" + id + "/log");
		assertTrue(logs.contains("job manager log"));

		FileUtils.writeStringToFile(logFiles.stdOutFile, "job manager out");
		logs = TestBaseUtils.getFromHTTP("http://localhost:" + port + "/taskmanagers/" + id + "/stdout");
		assertTrue(logs.contains("job manager out"));
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:27,
代码来源:WebFrontendITCase.java

示例28: disableStdOutErr

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@BeforeClass
public static void disableStdOutErr() {
	class NullPrint extends OutputStream {
		@Override
		public void write(int b) {}
	}

	PrintStream nullPrinter = new PrintStream(new NullPrint());
	System.setOut(nullPrinter);
	System.setErr(nullPrinter);

	// Unset FLINK_CONF_DIR, as this is a precondition for this test to work properly
	Map<String, String> map = new HashMap<>(System.getenv());
	map.remove(ConfigConstants.ENV_FLINK_CONF_DIR);
	TestBaseUtils.setEnv(map);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:17,
代码来源:CliFrontendYarnAddressConfigurationTest.java

示例29: teardown

点赞 3

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@AfterClass
public static void teardown() throws Exception {
	if (actorSystem != null ) {
		JavaTestKit.shutdownActorSystem(actorSystem);
		actorSystem = null;
	}

	if (zkServer != null) {
		zkServer.close();
		zkServer = null;
	}

	if (cluster != null) {
		TestBaseUtils.stopCluster(cluster, timeout);
	}
}
 

开发者ID:dataArtisans,
项目名称:query-window-example,
代码行数:17,
代码来源:TestQueryableWindowOperator.java

示例30: testTableSourceProjection

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testTableSourceProjection() throws Exception {

	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(4);
	BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, new TableConfig());
	HBaseTableSource hbaseTable = new HBaseTableSource(getConf(), TEST_TABLE);
	hbaseTable.addColumn(FAMILY1, F1COL1, Integer.class);
	hbaseTable.addColumn(FAMILY2, F2COL1, String.class);
	hbaseTable.addColumn(FAMILY2, F2COL2, Long.class);
	hbaseTable.addColumn(FAMILY3, F3COL1, Double.class);
	hbaseTable.addColumn(FAMILY3, F3COL2, Boolean.class);
	hbaseTable.addColumn(FAMILY3, F3COL3, String.class);
	tableEnv.registerTableSource("hTable", hbaseTable);

	Table result = tableEnv.sqlQuery(
		"SELECT " +
			"  h.family1.col1, " +
			"  h.family3.col1, " +
			"  h.family3.col2, " +
			"  h.family3.col3 " +
			"FROM hTable AS h"
	);
	DataSet<Row> resultSet = tableEnv.toDataSet(result, Row.class);
	List<Row> results = resultSet.collect();

	String expected =
		"10,1.01,false,Welt-1\n" +
		"20,2.02,true,Welt-2\n" +
		"30,3.03,false,Welt-3\n" +
		"40,4.04,true,Welt-4\n" +
		"50,5.05,false,Welt-5\n" +
		"60,6.06,true,Welt-6\n" +
		"70,7.07,false,Welt-7\n" +
		"80,8.08,true,Welt-8\n";

	TestBaseUtils.compareResultAsText(results, expected);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:39,
代码来源:HBaseConnectorITCase.java

示例31: testTableSourceFieldOrder

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testTableSourceFieldOrder() throws Exception {

	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(4);
	BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, new TableConfig());
	HBaseTableSource hbaseTable = new HBaseTableSource(getConf(), TEST_TABLE);
	// shuffle order of column registration
	hbaseTable.addColumn(FAMILY2, F2COL1, String.class);
	hbaseTable.addColumn(FAMILY3, F3COL1, Double.class);
	hbaseTable.addColumn(FAMILY1, F1COL1, Integer.class);
	hbaseTable.addColumn(FAMILY2, F2COL2, Long.class);
	hbaseTable.addColumn(FAMILY3, F3COL2, Boolean.class);
	hbaseTable.addColumn(FAMILY3, F3COL3, String.class);
	tableEnv.registerTableSource("hTable", hbaseTable);

	Table result = tableEnv.sqlQuery(
		"SELECT * FROM hTable AS h"
	);
	DataSet<Row> resultSet = tableEnv.toDataSet(result, Row.class);
	List<Row> results = resultSet.collect();

	String expected =
		"Hello-1,100,1.01,false,Welt-1,10\n" +
		"Hello-2,200,2.02,true,Welt-2,20\n" +
		"Hello-3,300,3.03,false,Welt-3,30\n" +
		"null,400,4.04,true,Welt-4,40\n" +
		"Hello-5,500,5.05,false,Welt-5,50\n" +
		"Hello-6,600,6.06,true,Welt-6,60\n" +
		"Hello-7,700,7.07,false,Welt-7,70\n" +
		"null,800,8.08,true,Welt-8,80\n";

	TestBaseUtils.compareResultAsText(results, expected);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:35,
代码来源:HBaseConnectorITCase.java

示例32: testTableSourceReadAsByteArray

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testTableSourceReadAsByteArray() throws Exception {

	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(4);
	BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, new TableConfig());
	// fetch row2 from the table till the end
	HBaseTableSource hbaseTable = new HBaseTableSource(getConf(), TEST_TABLE);
	hbaseTable.addColumn(FAMILY2, F2COL1, byte[].class);
	hbaseTable.addColumn(FAMILY2, F2COL2, byte[].class);

	tableEnv.registerTableSource("hTable", hbaseTable);
	tableEnv.registerFunction("toUTF8", new ToUTF8());
	tableEnv.registerFunction("toLong", new ToLong());

	Table result = tableEnv.sqlQuery(
		"SELECT " +
			"  toUTF8(h.family2.col1), " +
			"  toLong(h.family2.col2) " +
			"FROM hTable AS h"
	);
	DataSet<Row> resultSet = tableEnv.toDataSet(result, Row.class);
	List<Row> results = resultSet.collect();

	String expected =
		"Hello-1,100\n" +
		"Hello-2,200\n" +
		"Hello-3,300\n" +
		"null,400\n" +
		"Hello-5,500\n" +
		"Hello-6,600\n" +
		"Hello-7,700\n" +
		"null,800\n";

	TestBaseUtils.compareResultAsText(results, expected);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:37,
代码来源:HBaseConnectorITCase.java

示例33: getConfigurations

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Parameters
public static Collection<Object[]> getConfigurations() throws FileNotFoundException, IOException {

	LinkedList<Configuration> tConfigs = new LinkedList<Configuration>();

	for (int i = 1; i <= NUM_PROGRAMS; i++) {
		Configuration config = new Configuration();
		config.setInteger("ProgramId", i);
		tConfigs.add(config);
	}

	return TestBaseUtils.toParameterList(tConfigs);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:14,
代码来源:HadoopIOFormatsITCase.java

示例34: getFrontPage

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void getFrontPage() {
	try {
		String fromHTTP = TestBaseUtils.getFromHTTP("http://localhost:" + port + "/index.html");
		String text = "Apache Flink Dashboard";
		assertTrue("Startpage should contain " + text, fromHTTP.contains(text));
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:13,
代码来源:WebFrontendITCase.java

示例35: testConnectedComponentsWithParametrizableConvergence

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testConnectedComponentsWithParametrizableConvergence() throws Exception {

	// name of the aggregator that checks for convergence
	final String updatedElements = "updated.elements.aggr";

	// the iteration stops if less than this number of elements change value
	final long convergenceThreshold = 3;

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple2<Long, Long>> initialSolutionSet = env.fromCollection(verticesInput);
	DataSet<Tuple2<Long, Long>> edges = env.fromCollection(edgesInput);

	IterativeDataSet<Tuple2<Long, Long>> iteration = initialSolutionSet.iterate(10);

	// register the convergence criterion
	iteration.registerAggregationConvergenceCriterion(updatedElements,
		new LongSumAggregator(), new UpdatedElementsConvergenceCriterion(convergenceThreshold));

	DataSet<Tuple2<Long, Long>> verticesWithNewComponents = iteration.join(edges).where(0).equalTo(0)
		.with(new NeighborWithComponentIDJoin())
		.groupBy(0).min(1);

	DataSet<Tuple2<Long, Long>> updatedComponentId =
		verticesWithNewComponents.join(iteration).where(0).equalTo(0)
			.flatMap(new MinimumIdFilter(updatedElements));

	List<Tuple2<Long, Long>> result = iteration.closeWith(updatedComponentId).collect();
	Collections.sort(result, new TestBaseUtils.TupleComparator<Tuple2<Long, Long>>());

	assertEquals(expectedResult, result);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:34,
代码来源:AggregatorConvergenceITCase.java

示例36: testDeltaConnectedComponentsWithParametrizableConvergence

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@Test
public void testDeltaConnectedComponentsWithParametrizableConvergence() throws Exception {

	// name of the aggregator that checks for convergence
	final String updatedElements = "updated.elements.aggr";

	// the iteration stops if less than this number of elements change value
	final long convergenceThreshold = 3;

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple2<Long, Long>> initialSolutionSet = env.fromCollection(verticesInput);
	DataSet<Tuple2<Long, Long>> edges = env.fromCollection(edgesInput);

	DeltaIteration<Tuple2<Long, Long>, Tuple2<Long, Long>> iteration =
		initialSolutionSet.iterateDelta(initialSolutionSet, 10, 0);

	// register the convergence criterion
	iteration.registerAggregationConvergenceCriterion(updatedElements,
		new LongSumAggregator(), new UpdatedElementsConvergenceCriterion(convergenceThreshold));

	DataSet<Tuple2<Long, Long>> verticesWithNewComponents = iteration.getWorkset().join(edges).where(0).equalTo(0)
		.with(new NeighborWithComponentIDJoin())
		.groupBy(0).min(1);

	DataSet<Tuple2<Long, Long>> updatedComponentId =
		verticesWithNewComponents.join(iteration.getSolutionSet()).where(0).equalTo(0)
			.flatMap(new MinimumIdFilter(updatedElements));

	List<Tuple2<Long, Long>> result = iteration.closeWith(updatedComponentId, updatedComponentId).collect();
	Collections.sort(result, new TestBaseUtils.TupleComparator<Tuple2<Long, Long>>());

	assertEquals(expectedResult, result);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:35,
代码来源:AggregatorConvergenceITCase.java

示例37: setup

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
	// make sure we do not use a singleActorSystem for the tests
	// (therefore, we cannot simply inherit from StreamingMultipleProgramsTestBase)
	LOG.info("Starting FlinkMiniCluster");
	cluster = TestBaseUtils.startCluster(1, DEFAULT_PARALLELISM, false, false, false);
	TestStreamEnvironment.setAsContext(cluster, DEFAULT_PARALLELISM);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:9,
代码来源:BigUserProgramJobSubmitITCase.java

示例38: checkSql

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
/**
 * Execute SQL query and check results.
 *
 * @param query    SQL query.
 * @param expected Expected result.
 */
private void checkSql(String query, String expected) throws Exception {
	Table resultTable = tableEnv.sql(query);
	DataSet<Row> resultDataSet = tableEnv.toDataSet(resultTable, Row.class);
	List<Row> results = resultDataSet.collect();
	TestBaseUtils.compareResultAsText(results, expected);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:13,
代码来源:GroupingSetsITCase.java

示例39: compareSql

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
private void compareSql(String query1, String query2) throws Exception {

		// Function to map row to string
		MapFunction<Row, String> mapFunction = new MapFunction<Row, String>() {

			@Override
			public String map(Row value) throws Exception {
				return value == null ? "null" : value.toString();
			}
		};

		// Execute first query and store results
		Table resultTable1 = tableEnv.sql(query1);
		DataSet<Row> resultDataSet1 = tableEnv.toDataSet(resultTable1, Row.class);
		List<String> results1 = resultDataSet1.map(mapFunction).collect();

		// Execute second query and store results
		Table resultTable2 = tableEnv.sql(query2);
		DataSet<Row> resultDataSet2 = tableEnv.toDataSet(resultTable2, Row.class);
		List<String> results2 = resultDataSet2.map(mapFunction).collect();

		// Compare results
		TestBaseUtils.compareResultCollections(results1, results2, new Comparator<String>() {

			@Override
			public int compare(String o1, String o2) {
				return o2 == null ? o1 == null ? 0 : 1 : o1.compareTo(o2);
			}
		});
	}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:31,
代码来源:GroupingSetsITCase.java

示例40: checkSql

点赞 2

import org.apache.flink.test.util.TestBaseUtils; //导入依赖的package包/类
/**
 * Execute SQL query and check results.
 *
 * @param query    SQL query.
 * @param expected Expected result.
 */
private void checkSql(String query, String expected) throws Exception {
	Table resultTable = tableEnv.sqlQuery(query);
	DataSet<Row> resultDataSet = tableEnv.toDataSet(resultTable, Row.class);
	List<Row> results = resultDataSet.collect();
	TestBaseUtils.compareResultAsText(results, expected);
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:13,
代码来源:GroupingSetsITCase.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)