Project

General

Profile

1
package eu.dnetlib.msro.workflows.hadoop.hbase;
2

    
3
import com.googlecode.sarasvati.NodeToken;
4
import eu.dnetlib.data.hadoop.rmi.HadoopService;
5
import org.apache.commons.logging.Log;
6
import org.apache.commons.logging.LogFactory;
7

    
8
public class ExistHBaseTableJobNode extends AbstractHBaseAdminJobNode {
9

    
10
	private static final Log log = LogFactory.getLog(ExistHBaseTableJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
11

    
12
	private String existOutNode;
13

    
14
	private String dontExistOutNode;
15

    
16
	@Override
17
	protected String execute(final NodeToken token) throws Exception {
18
		final String tableName = tableName(token);
19
		final String cluster = cluster(token);
20

    
21
		log.info("checking table existance: '" + tableName + "' on cluster: '" + cluster + "'");
22

    
23
		final HadoopService hadoopService = getServiceLocator().getService(HadoopService.class);
24
		boolean exists = hadoopService.existHbaseTable(cluster, tableName);
25

    
26
		log.info("table '" + tableName + "' exists: " + exists);
27

    
28
		if (exists) {
29
			final String tableDesc = hadoopService.describeHBaseTableConfiguration(cluster, tableName);
30
			token.getEnv().setAttribute(getTableConfigurationParamName(), tableDesc);
31
		}
32

    
33
		return exists ? getExistOutNode() : getDontExistOutNode();
34
	}
35

    
36
	public String getExistOutNode() {
37
		return existOutNode;
38
	}
39

    
40
	public void setExistOutNode(final String existOutNode) {
41
		this.existOutNode = existOutNode;
42
	}
43

    
44
	public String getDontExistOutNode() {
45
		return dontExistOutNode;
46
	}
47

    
48
	public void setDontExistOutNode(final String dontExistOutNode) {
49
		this.dontExistOutNode = dontExistOutNode;
50
	}
51

    
52
}
(7-7/10)