Time of Update: 2018-07-26
本篇學習筆記來源於ES官方網站的指導文檔:ES JAVA API Client Client是一個類,通過這個類可以實現對ES叢集的各種操作:Index, Get, Delete , Search,以及對ES叢集的管理工作。 Client的構造需要基於TransportClient TransportClient
Time of Update: 2018-07-26
自己今天想到死結,就試著寫了一個。package com.ljl.thread;public class DealLock implements Runnable {private int flag = 1;// 此對象必須是靜態,同步必須是被多個線程共用static Object resource1 = new Object(), resource2 = new Object();public void run() {if (flag == 1) {synchronized
Time of Update: 2018-07-26
這裡是一個檔案上傳的工具類,通用性很強。廢話不多說,直奔主題。如有疑問或錯誤,歡迎指正交流。 public class FileUploadUtils { private static final Logger logger = LoggerFactory.getLogger(FileUploadUtils.class); public static String getUploadPath(HttpServletRequest request){
Time of Update: 2018-07-26
操作方式:使用HDFS的API 直接讀取檔案: 解決辦法: 第一種方法: 原始碼:FileSystem fs = FileSystem.get(URI.create(hdfsFilePath), config); 改為: FileSystem fs = FileSystem.newInstance(URI.create(hdfsFilePath), config); 第二種方法: 在hdfs core-site.
Time of Update: 2018-07-26
Java資料統計 spark版本2.1.2,包含Dateset使用,SparkStreaming資料統計 項目地址為https://github.com/baifanwudi/big-data-analysis 程式碼範例 SparkSql demo: 讀取json檔案寫入hive package com.adups.offline.hive.log;import com.adups.base.AbstractSparkSql;import
Time of Update: 2018-07-26
異常說明 java.lang.SecurityException: class “javax.servlet.FilterRegistration“‘s signer information does not match signer information of other classes in the same package 解決誤區 在ideal中運行本地spark出現class “javax.servlet.FilterRegistration”
Time of Update: 2018-07-26
JMSReplyTo 當Producer發送一個Message時,通過指定其Message Header中的JMSReplyTo屬性,指定一個Destination;當Consumer接收到訊息時,可以通過getXXX()方法取得這個Destination,進而可選擇是否向這個Destination發送一些Message(任意);而原Producer也可以選擇同時監聽這一Destination,從而可以收到一些Consumer發送的Message。
Time of Update: 2018-07-26
單點傳輸——訊息的對應的資料通道是隊列Queue,訊息生產者QueueSender和訊息消費者QueueReceiver javax.jms public interface QueueSender extends MessageProducerpublic interface QueueReceiver extends MessageConsumer 和Queue相關的介面還有: javax.jmspublic interface
Time of Update: 2018-07-26
2014-2-17 12:12:11 org.apache.catalina.core.AprLifecycleListener init 資訊: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.4.8. 2014-2-17 12:12:11 org.apache.catalina.core.AprLifecycleListener init 資訊: APR
Time of Update: 2018-07-26
在執行前,設定了參數Goals: compile compile exec:java -Dexec.mainClass=”com.weimenhu.appUtil.test” 網上尋找資料,在 http://www.cnblogs.com/csophys/archive/2012/05/18/2507926.html 中找到是因為沒有遵守Maven約定造成的:
Time of Update: 2018-07-26
1.問題描述 往叢集提交任務的時候,需要在hdfs上面讀取一個資源檔。在讀取該資源檔的時候,代碼爆出如下異常: Error: java.io.IOException: Filesystem closed at org.apache.hadoop.hdfs.DFSClient.checkOpen(DFSClient.java:823) at
Time of Update: 2018-07-26
說明: 1.PreparedStatement介面繼承Statement,它的執行個體包含已編譯的SQL語句,執行速度要快於Statement。 2.PreparedStatement繼承了Statement的所有功能,三種方法executeUpdate、executeQuery、execute不再需要參數。 3.在JDBC應用中,一般都用PreparedStatement,而不是Statement。 便於操作,先做一些封裝:
Time of Update: 2018-07-26
Memcach什麼是Memcache Memcache叢集環境下緩衝解決方案 Memcache是一個高效能的分布式的記憶體對象緩衝系統,通過在記憶體裡維護一個統一的巨大的hash表,它能夠用來儲存各種格式的資料,包括映像、視頻、檔案以及資料庫檢索的結果等。簡單的說就是將資料調用到記憶體中,然後從記憶體中讀取,從而大大提高讀取速度。 Memcache是danga的一個項目,最早是LiveJournal 服務的,最初為了加速 LiveJournal
Time of Update: 2018-07-26
1、short s1 = 1; s1 = s1 + 1;有錯嗎?short s1 = 1; s1 += 1;有錯嗎。 答案:s1 = s1+1 ; 會提示“cannot convert from int to short”,1本身是int類型,而s1是短整型,所以他們二者運算結果是int類型,要想使運算式成立,需要將結果強制轉換成short類型 s1+=1;相當於s1 = (short)(s1 + 1);其中有隱含的強制類型轉換。所以編譯不會有問題。 2、int和Integer的區別。
Time of Update: 2018-07-26
最近寫了一個連資料庫的程式,發現老是記憶體不夠. 最後發現是statement 沒有及時關閉,佔用了大量資源. 源碼如下 public static int executeUpdate(String sql){Statement stmt=null;int count=0;try {stmt = conn.createStatement();count = stmt.executeUpdate(sql);}catch (SQLException e)
Time of Update: 2018-07-26
1 單例模型,對資源進行共用。 類如ListTest,用Test類進行測試。 import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock; public class
Time of Update: 2018-07-26
給定某個日期,怎麼獲得這個日期的後一天呢。這不是單純的當前日期加一的事情。某年的最後一天,某月的最後一天加一會轉到下一個月,這樣一來就會出錯。下面給出一個簡單的方法,用的是日曆類提供的方法。話不多說直接上代碼。 public static String getTheNextDate(String date){//201711191600if (date!=null&&date.length()>=8) {date=date.substring(0, 8);}else {
Time of Update: 2018-07-26
1.使用Character.isDigit(char)判斷String str = "123abc";if (!"".equals(str)) { char num[] = str.toCharArray();//把字串轉換為字元數組 StringBuffer title = new StringBuffer();//使用StringBuffer類,把非數字放到title中
Time of Update: 2018-07-26
resultMap中,通常使用id、result子項目把Java實體類的屬性對應到資料庫表的欄位上。但是如果在遇到JavaBean只有有參建構函式時,我還需要使用構造器元素實現一個JavaBean的執行個體化和資料注入。今天小博老師就帶領大家一起學習下ResultMap中的構造器元素constructor的使用方法。 繼續我們之前的User類,我們加入一個建構函式: 對應的,resultMap應該做如下修改:
Time of Update: 2018-07-26
DeliveryMode指明訊息的傳輸模式: DeliveryMode.NON_PERSISTENT —— 表示訊息在被消費之前,如果JMS Providers(如Active MQ)DOWN了,重新啟動後訊息不存在。 DeliveryMode.PERSISTENT —— 表示訊息在被消費之前,如果JMS Providers(如Active MQ)DOWN了,重新啟動後訊息仍然存在。 可以通過Producer來設定,