Revision 31415
Added by Claudio Atzori over 9 years ago
ExistHBaseTableJobNode.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.apache.commons.logging.Log; |
4 | 4 |
import org.apache.commons.logging.LogFactory; |
5 |
import org.springframework.beans.factory.annotation.Autowired; |
|
6 | 5 |
|
7 | 6 |
import com.googlecode.sarasvati.NodeToken; |
8 | 7 |
|
9 |
import eu.dnetlib.data.hadoop.rmi.HadoopService; |
|
10 |
import eu.dnetlib.enabling.tools.ServiceLocator; |
|
11 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
8 |
public class ExistHBaseTableJobNode extends AbstractHBaseAdminJobNode { |
|
12 | 9 |
|
13 |
public class ExistHBaseTableJobNode extends SimpleJobNode { |
|
14 |
|
|
15 | 10 |
private static final Log log = LogFactory.getLog(ExistHBaseTableJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM |
16 | 11 |
|
17 |
private String hbaseTableProperty; |
|
18 |
private String cluster; |
|
19 |
|
|
20 |
@Autowired |
|
21 |
private ServiceLocator<HadoopService> hadoopServiceLocator; |
|
22 |
|
|
23 | 12 |
@Override |
24 | 13 |
protected String execute(final NodeToken token) throws Exception { |
25 |
final String tableName = tableName(); |
|
14 |
final String tableName = tableName(token); |
|
15 |
final String cluster = cluster(token); |
|
26 | 16 |
|
27 |
log.info("checking table existance: '" + tableName + "'"); |
|
17 |
log.info("checking table existance: '" + tableName + "' on cluster: '" + cluster + "'");
|
|
28 | 18 |
|
29 | 19 |
boolean exists = hadoopServiceLocator.getService().existHbaseTable(cluster, tableName); |
30 | 20 |
|
... | ... | |
33 | 23 |
return exists ? "drop" : "create"; |
34 | 24 |
} |
35 | 25 |
|
36 |
private String tableName() { |
|
37 |
return getPropertyFetcher().getProperty(getHbaseTableProperty()); |
|
38 |
} |
|
39 |
|
|
40 |
public String getCluster() { |
|
41 |
return cluster; |
|
42 |
} |
|
43 |
|
|
44 |
public void setCluster(final String cluster) { |
|
45 |
this.cluster = cluster; |
|
46 |
} |
|
47 |
|
|
48 |
public String getHbaseTableProperty() { |
|
49 |
return hbaseTableProperty; |
|
50 |
} |
|
51 |
|
|
52 |
public void setHbaseTableProperty(String hbaseTableProperty) { |
|
53 |
this.hbaseTableProperty = hbaseTableProperty; |
|
54 |
} |
|
55 |
|
|
56 | 26 |
} |
Also available in: Unified diff
refactored submit job nodes, introducing AdminJobNodes