Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
(c) Copyright 2014 Hewlett-Packard Development Company, L.P. All rights reserved. This program and the accompanying materials are made available under the terms of the Apache License v2.0 which accompany this distribution. The Apache License is available at http://www.apache.org/licenses/LICENSE-2.0 /
 
package org.openscore.worker.management;
import  org.apache.log4j.Logger;
import  org.openscore.engine.node.entities.WorkerNode;
import  org.openscore.engine.node.services.WorkerNodeService;

Author(s):
stoneo
Avi Moradi
Since:
15/07/2014
public class WorkerRegistration {
	private static final Logger log = Logger.getLogger(WorkerRegistration.class);
	protected String workerUuid;
	protected WorkerNodeService workerNodeService;
	public void registerWorkerPostConstruct() throws Exception {
		try {
catch(Exception ex) {
			.error("Failed to register worker due to: " + ex.getMessage(), ex);
			throw ex;
		}
	}
	protected void registerWorker() throws Exception {
		try {
			WorkerNode workerNode = .readByUUID();
			if(workerNode != null) {
				.info("Worker already registered: " + workerNode);
				return;
			}
catch(Exception ex) { /* Worker not found, register it */ }
		.info("Registering worker " + );
		String password = UUID.randomUUID().toString();
		createWorker(password, System.getProperty("user.dir"));
	}
	protected void createWorker(String uuidString passwordString installPaththrows UnknownHostException {
		.info("Creating worker...");
		.create(uuidpassword, InetAddress.getLocalHost().getCanonicalHostName(), installPath);
		.activate(uuid);
		.info("Worker [" + uuid + "] registered and activated");
	}
New to GrepCode? Check out our FAQ X