Project

General

Profile

« Previous | Next » 

Revision 47678

Added method to insert data into an hbase table

View differences:

modules/dnet-hadoop-service-rmi/trunk/src/main/java/eu/dnetlib/data/hadoop/rmi/HadoopService.java
231 231
			@WebParam(name = "column") HBaseRowDescriptor column) throws HadoopServiceException;
232 232

  
233 233
	/**
234
	 * Remove from an HBase table the values identified by a row descriptor.
234
	 * Remove from an HBase table the values identified by the given row descriptors.
235 235
	 *
236 236
	 * @param clusterName
237 237
	 * @param tableName
......
242 242
			@WebParam(name = "tableName") String tableName,
243 243
			@WebParam(name = "column") List<HBaseRowDescriptor> column) throws HadoopServiceException;
244 244

  
245
	/**
246
	 *
247
	 * Add to an HBase table the value into the cell identified by coordinates rowKey, columnFamily and qualifier.
248
	 *
249
	 * @param clusterName
250
	 * @param tableName
251
	 * @param rowKey
252
	 * @param columnFamily
253
	 * @param qualifier
254
	 * @param value: base64 encoding of the protobuffer value
255
	 * @throws HadoopServiceException
256
	 */
257
	void addHBaseColumn(@WebParam(name = "clusterName") String clusterName,
258
			@WebParam(name = "tableName") String tableName,
259
			@WebParam(name = "rowKey") String rowKey,
260
			@WebParam(name = "columnFamily") String columnFamily,
261
			@WebParam(name = "qualifier") String qualifier,
262
			@WebParam(name="value") String value) throws HadoopServiceException;
263

  
245 264
}
modules/dnet-hadoop-service/trunk/src/main/java/eu/dnetlib/data/hadoop/HadoopServiceImpl.java
15 15
import eu.dnetlib.data.hadoop.rmi.hbase.HBaseRowDescriptor;
16 16
import eu.dnetlib.enabling.tools.AbstractBaseService;
17 17
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
18
import org.apache.commons.codec.binary.Base64;
19
import org.apache.commons.logging.Log;
20
import org.apache.commons.logging.LogFactory;
18 21
import org.apache.hadoop.conf.Configuration;
22
import org.apache.hadoop.hbase.client.Put;
23
import org.apache.hadoop.hbase.util.Bytes;
19 24
import org.springframework.beans.factory.annotation.Autowired;
20 25
import org.springframework.beans.factory.annotation.Required;
21 26

  
......
24 29
 */
25 30
public class HadoopServiceImpl extends AbstractBaseService implements HadoopService {
26 31

  
32
	private static final Log log = LogFactory.getLog(HadoopServiceImpl.class);
27 33
	/**
28 34
	 * notification handler.
29 35
	 */
......
279 285
		}
280 286
	}
281 287

  
288
	@Override
289
	public void addHBaseColumn(final String clusterName,
290
			final String tableName,
291
			final String rowKey,
292
			final String columnFamily,
293
			final String qualifier,
294
			final String value)
295
			throws HadoopServiceException {
296
		log.debug(String.format("adding value to K: '%s' CF:'%s' Q:'%s'", rowKey, columnFamily, qualifier));
297
		final Put put = new Put(Bytes.toBytes(rowKey)).add(Bytes.toBytes(columnFamily), Bytes.toBytes(qualifier), Base64.decodeBase64(value));
298
		try {
299
			hadoopServiceCore.writeOnHBase(ClusterName.valueOf(clusterName), tableName, Lists.newArrayList(put));
300
		} catch (IOException e) {
301
			throw new HadoopServiceException(e);
302
		}
303
	}
304

  
305

  
306

  
282 307
	///////////////////
283 308

  
284 309
	/**

Also available in: Unified diff