package com.peony.netty.service; import com.peony.netty.util.HbaseFileSystem; import com.peony.util.StringUtils; import com.qingcloud.qingstor.Qingstor; import org.apache.hadoop.hbase.TableName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DocHtmlService { private static DocHtmlService instance = new DocHtmlService(); private final TableName tableContent = TableName.valueOf("doc_html"); private final String bucketHtml = "doc-html"; private Logger logger = LoggerFactory.getLogger(DocHtmlService.class); private HbaseFileSystem fileSystem = HbaseFileSystem.getInstance(); public static DocHtmlService getInstance() { return instance; } public String get(String id, boolean depress) { String html = null; try { // html = fileSystem.get(id, tableContent, depress); } catch (Exception e) { logger.error(e.getMessage(), e); } if (StringUtils.isEmpty(html)) { try { String htmlCompress = Qingstor.getObject(bucketHtml, id); html = depress ? StringUtils.depressString(htmlCompress) : htmlCompress; } catch (Exception e) { logger.error(e.getMessage(), e); } } if (html == null) { logger.warn("查询id: " + id + " HTML为空"); return null; } return html; } }