Project

General

Profile

« Previous | Next » 

Revision 42198

ensuring basePath exists upon service startup

View differences:

modules/dnet-actionmanager-service/trunk/src/main/java/eu/dnetlib/actionmanager/hbase/HBaseClient.java
22 22
import eu.dnetlib.data.hadoop.config.ClusterName;
23 23
import eu.dnetlib.data.hadoop.rmi.HadoopServiceException;
24 24
import eu.dnetlib.data.proto.OafProtos.Oaf;
25
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
26
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
27
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
25 28
import org.apache.commons.logging.Log;
26 29
import org.apache.commons.logging.LogFactory;
27 30
import org.apache.hadoop.hbase.client.Delete;
......
33 36
import org.apache.hadoop.hbase.filter.PageFilter;
34 37
import org.apache.hadoop.hbase.filter.PrefixFilter;
35 38
import org.apache.hadoop.hbase.util.Bytes;
39
import org.springframework.beans.factory.annotation.Autowired;
36 40
import org.springframework.beans.factory.annotation.Required;
37 41

  
38 42
public class HBaseClient {
......
50 54
	@Resource
51 55
	private HadoopServiceCore hadoopServiceCore;
52 56

  
57
	@Autowired
58
	private UniqueServiceLocator serviceLocator;
59

  
53 60
	private final Function<Result, Map<String, String>> transformRow = new Function<Result, Map<String, String>>() {
54 61

  
55 62
		@Override
......
92 99
					Thread.sleep(getStartDelay());
93 100
					log.info("Initializing Action Manager");
94 101
					prepareTable(delete);
102
					prepareBasePath();
95 103
					log.info("ActionManager is ready");
96 104
				} catch (final Exception e) {
97 105
					log.error("Error initializing action manager", e);
......
100 108
		});
101 109
	}
102 110

  
111
	private void prepareBasePath() throws ISLookUpException, HadoopServiceException {
112
		final String basePath = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(
113
				"/RESOURCE_PROFILE[./HEADER/RESOURCE_TYPE/@value='ActionManagerServiceResourceType']//SERVICE_PROPERTIES/PROPERTY[@key='basePath']/@value/string()");
114

  
115
		hadoopServiceCore.createHdfsDir(ClusterName.DM, basePath, false);
116
	}
117

  
118
	@Deprecated
103 119
	private void prepareTable(final boolean delete) throws HadoopServiceException, IOException {
104 120
		final Set<String> columns = new HashSet<String>();
105 121
		for (final COLUMN_FAMILIES cf : ActionManagerConstants.COLUMN_FAMILIES.values()) {

Also available in: Unified diff