/* * Copyright 2014 NAVER Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.navercorp.pinpoint.collector.dao.hbase; import static com.navercorp.pinpoint.common.hbase.HBaseTables.*; import com.navercorp.pinpoint.collector.dao.ApplicationIndexDao; import com.navercorp.pinpoint.common.hbase.HbaseOperations2; import com.navercorp.pinpoint.thrift.dto.TAgentInfo; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.util.Bytes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; /** * application names list. * * @author netspider * @author emeroad */ @Repository public class HbaseApplicationIndexDao implements ApplicationIndexDao { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private HbaseOperations2 hbaseTemplate; @Override public void insert(final TAgentInfo agentInfo) { if (agentInfo == null) { throw new NullPointerException("agentInfo must not be null"); } Put put = new Put(Bytes.toBytes(agentInfo.getApplicationName())); byte[] qualifier = Bytes.toBytes(agentInfo.getAgentId()); byte[] value = Bytes.toBytes(agentInfo.getServiceType()); put.addColumn(APPLICATION_INDEX_CF_AGENTS, qualifier, value); hbaseTemplate.put(APPLICATION_INDEX, put); logger.debug("Insert agentInfo. {}", agentInfo); } }