Skip to content

olegz/yaya

Repository files navigation

Try and YARN in less then 5

This project is an R&D effort (for now) with the main goal of defining and discovering a simpler (developer friendly) ways of using YARN, allowing end user to concentrate on the functional aspects of an application while delegating infrastructure and boilerplate code dealing with YARN internals to the framework.

YARN could and should be as simple as:

Unix command Application Container:

YarnApplication<Void> yarnApplication = YarnAssembly.forApplicationContainer("ping -c 4 yahoo.com").
										containerCount(4).
										withApplicationMaster().
												build("Simplest-Yarn-Command-Application");
		
yarnApplication.launch();

. . . or

Java process Application Container:

YarnConfiguration yarnConfiguration = new YarnConfiguration();
YarnApplication<Void> yarnApplication = 
	YarnAssembly.forApplicationContainer(ReverseMessageContainer.class, ByteBuffer.wrap("Hello Yarn!".getBytes())).
						containerCount(4).
						withApplicationMaster(yarnConfiguration).
							build("Simplest-Yarn-Java-Application");
		
yarnApplication.launch();

. . .

public static class ReverseMessageContainer implements ApplicationContainer {
		@Override
		public ByteBuffer process(ByteBuffer inputMessage) {
			inputMessage.rewind();
			byte[] inputBytes = new byte[inputMessage.limit()];
			inputMessage.get(inputBytes);
			String reversedMessage = new StringBuilder(new String(inputBytes)).reverse().toString();
			System.out.println("Processing input: " + reversedMessage);
			return null;
			// You can also return ByteBuffer, but since its a single task container
			// the contents of the returned ByteBuffer will be logged.
			//return ByteBuffer.wrap(strMessage.getBytes());
		}
}

This is an evolving work in progress so more updates (code and documentation) will be coming soon

Please send question and updates via pull requests and/or raising issues on this project.