Commit 33a89921 by Amir Aharon

1.3.4 - remove Log4jHandler from JsonHandler and other utils

parent 9af8aaa0
### general utils ### general utils
## 1.2.0: support PATCH method in http request ## 1.3.4
## 1.1.4: overriding config file properties with env - remove Log4jHandler from JsonHandler and other utils
## 1.2.5
- support 'assumeContentBinary' flag
## 1.2.4
- support binary content in response
## 1.2.3: ## 1.2.3:
- add "mavenLocal", for local repository. enables to check this dependency locally - add "mavenLocal", for local repository. enables to check this dependency locally
- Handle correctly Exceptions in http requsts/responses - Handle correctly Exceptions in http requsts/responses
- support Encoding type (other than utf8) in http responses - support Encoding type (other than utf8) in http responses
## 1.2.4 ## 1.2.0: support PATCH method in http request
- support binary content in response ## 1.1.4: overriding config file properties with env
## 1.2.5
- support 'assumeContentBinary' flag
\ No newline at end of file
group 'com.ipgallery.common' group 'com.ipgallery.common'
version '1.3.3' version '1.3.4'
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
......
...@@ -9,7 +9,7 @@ import java.io.IOException; ...@@ -9,7 +9,7 @@ import java.io.IOException;
public class JsonHandler { public class JsonHandler {
private static final Log4jHandler logger = new Log4jHandler(JsonHandler.class.getName()); // private static final Log4jHandler logger = new Log4jHandler(JsonHandler.class.getName());
private static final ObjectMapper SORTED_MAPPER = new ObjectMapper(); private static final ObjectMapper SORTED_MAPPER = new ObjectMapper();
static { static {
...@@ -23,7 +23,7 @@ public class JsonHandler { ...@@ -23,7 +23,7 @@ public class JsonHandler {
objString = SORTED_MAPPER.writeValueAsString(obj); objString = SORTED_MAPPER.writeValueAsString(obj);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
logger.error("in getObjectAsJsonString", e); System.err.println("in getObjectAsJsonString" + e);
} }
return objString; return objString;
} }
......
...@@ -11,7 +11,7 @@ import org.apache.commons.io.monitor.FileAlterationObserver; ...@@ -11,7 +11,7 @@ import org.apache.commons.io.monitor.FileAlterationObserver;
*/ */
public class Log4jFileAlterationListenerImpl implements FileAlterationListener { public class Log4jFileAlterationListenerImpl implements FileAlterationListener {
Log4jHandler logger = new Log4jHandler(Log4jFileAlterationListenerImpl.class.getName()); // Log4jHandler logger = new Log4jHandler(Log4jFileAlterationListenerImpl.class.getName());
/** /**
* {@inheritDoc} * {@inheritDoc}
...@@ -73,9 +73,9 @@ public class Log4jFileAlterationListenerImpl implements FileAlterationListener { ...@@ -73,9 +73,9 @@ public class Log4jFileAlterationListenerImpl implements FileAlterationListener {
// logger.debug("----------> executable: " + file.canExecute()); // logger.debug("----------> executable: " + file.canExecute());
try { try {
org.apache.log4j.xml.DOMConfigurator.configure(fileName); org.apache.log4j.xml.DOMConfigurator.configure(fileName);
logger.warning("Log4j configuration has been reloaded from file < " + fileName + " >."); System.out.println("Log4j configuration has been reloaded from file < " + fileName + " >.");
} catch (Exception e) { } catch (Exception e) {
logger.debug("Failed to load XML File with exception: " + e); System.out.println("Failed to load XML File with exception: " + e);
} }
} }
} }
......
...@@ -4,13 +4,13 @@ import java.util.HashMap; ...@@ -4,13 +4,13 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import common.Log4jHandler; //import common.Log4jHandler;
public class MultiThreadQueueHander public class MultiThreadQueueHander
{ {
private final static Log4jHandler logger = new Log4jHandler(MultiThreadQueueHander.class.getName()); //private final static Log4jHandler logger = new Log4jHandler(MultiThreadQueueHander.class.getName());
private static MultiThreadQueueHander sInstance = null; private static MultiThreadQueueHander sInstance = null;
Map<String, MultiThreadQueueManager> mtqmMap = new HashMap<String, MultiThreadQueueManager>(); Map<String, MultiThreadQueueManager> mtqmMap = new HashMap<String, MultiThreadQueueManager>();
...@@ -48,7 +48,7 @@ public class MultiThreadQueueHander ...@@ -48,7 +48,7 @@ public class MultiThreadQueueHander
mtqmMap.put(name, mtqm); mtqmMap.put(name, mtqm);
} }
else else
logger.error("failed to start queue manager: " + name); System.err.println("failed to start queue manager: " + name);
} }
} }
return mtqm; return mtqm;
...@@ -61,7 +61,7 @@ public class MultiThreadQueueHander ...@@ -61,7 +61,7 @@ public class MultiThreadQueueHander
public synchronized void stop() public synchronized void stop()
{ {
logger.warning("Stopping the managers..."); System.out.println("Stopping the managers...");
for (Entry<String, MultiThreadQueueManager> mtqmEntry : mtqmMap.entrySet()) for (Entry<String, MultiThreadQueueManager> mtqmEntry : mtqmMap.entrySet())
{ {
if (mtqmEntry != null) if (mtqmEntry != null)
...@@ -69,7 +69,7 @@ public class MultiThreadQueueHander ...@@ -69,7 +69,7 @@ public class MultiThreadQueueHander
mtqmEntry.getValue().stopManager(); mtqmEntry.getValue().stopManager();
} }
} }
logger.warning("Stopped all managers, clearing..."); System.out.println("Stopped all managers, clearing...");
mtqmMap.clear(); mtqmMap.clear();
} }
......
...@@ -7,7 +7,7 @@ import java.util.ArrayDeque; ...@@ -7,7 +7,7 @@ import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import common.Log4jHandler; //import common.Log4jHandler;
/** /**
* this manager holds thread that handle async jobs * this manager holds thread that handle async jobs
...@@ -22,7 +22,7 @@ public class MultiThreadQueueManager ...@@ -22,7 +22,7 @@ public class MultiThreadQueueManager
{ {
protected List<JobThread> mJobThreadArray = null; protected List<JobThread> mJobThreadArray = null;
protected List <ItcMessageQueue> mJobQueueArray = null; protected List <ItcMessageQueue> mJobQueueArray = null;
private final static Log4jHandler logger = new Log4jHandler(MultiThreadQueueManager.class.getName()); // private final static Log4jHandler logger = new Log4jHandler(MultiThreadQueueManager.class.getName());
protected int mNumOfThreads = 0; protected int mNumOfThreads = 0;
protected int mQueueSize = 0; protected int mQueueSize = 0;
protected int mReceiveBulkSize = 0; protected int mReceiveBulkSize = 0;
...@@ -62,7 +62,7 @@ public class MultiThreadQueueManager ...@@ -62,7 +62,7 @@ public class MultiThreadQueueManager
} }
} catch (Exception e) } catch (Exception e)
{ {
logger.info(e.toString()); System.out.println(e.toString());
} }
} }
...@@ -83,7 +83,7 @@ public class MultiThreadQueueManager ...@@ -83,7 +83,7 @@ public class MultiThreadQueueManager
{ {
Runnable runJob = (Runnable) msg.getMsgObj(); Runnable runJob = (Runnable) msg.getMsgObj();
if (msg.getFromSender() != null) if (msg.getFromSender() != null)
logger.info("running job: " + runJob.getClass().getName() + ", sent from: " + msg.getFromSender() + System.out.println("running job: " + runJob.getClass().getName() + ", sent from: " + msg.getFromSender() +
" on thread: " + this.threadNumber); " on thread: " + this.threadNumber);
runJob.run(); runJob.run();
...@@ -132,7 +132,7 @@ public class MultiThreadQueueManager ...@@ -132,7 +132,7 @@ public class MultiThreadQueueManager
public boolean stopManager() public boolean stopManager()
{ {
logger.warning("Stopping the threads..."); System.out.println("Stopping the threads...");
for (JobThread thr : mJobThreadArray) for (JobThread thr : mJobThreadArray)
{ {
if (thr != null) if (thr != null)
...@@ -144,13 +144,13 @@ public class MultiThreadQueueManager ...@@ -144,13 +144,13 @@ public class MultiThreadQueueManager
thr.join(1000); thr.join(1000);
thr = null; thr = null;
} catch (InterruptedException e) } catch (InterruptedException e)
{ {
logger.severe(e.toString()); System.err.println(e.toString());
} }
} }
} }
mJobThreadArray.clear(); mJobThreadArray.clear();
logger.warning("threads stopped... and i did it my way!"); System.out.println("threads stopped... and i did it my way!");
return true; return true;
} }
......
...@@ -11,7 +11,7 @@ import java.util.Set; ...@@ -11,7 +11,7 @@ import java.util.Set;
import java.util.Timer; import java.util.Timer;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import common.Log4jHandler; //import common.Log4jHandler;
import mtqm.MultiThreadQueueManager; import mtqm.MultiThreadQueueManager;
/** /**
...@@ -26,7 +26,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager ...@@ -26,7 +26,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager
private final static int CANCEL_TASK = 2; private final static int CANCEL_TASK = 2;
private final static int EXECUTE_JOB = 3; private final static int EXECUTE_JOB = 3;
private final static String MY_NAME = MultiThreadQueueManager.class.getName(); private final static String MY_NAME = MultiThreadQueueManager.class.getName();
private final static Log4jHandler logger = new Log4jHandler(OfflineTaskManager.class.getName()); // private final static Log4jHandler logger = new Log4jHandler(OfflineTaskManager.class.getName());
private static OfflineTaskManager sInstance = null; private static OfflineTaskManager sInstance = null;
AtomicInteger currentThread = new AtomicInteger(0); AtomicInteger currentThread = new AtomicInteger(0);
...@@ -88,7 +88,6 @@ public class OfflineTaskManager extends MultiThreadQueueManager ...@@ -88,7 +88,6 @@ public class OfflineTaskManager extends MultiThreadQueueManager
OfflineTask ot = (OfflineTask)msg.getMsgObj(); OfflineTask ot = (OfflineTask)msg.getMsgObj();
if (ot.isValid()) if (ot.isValid())
{ {
logger.info("start : " + ot.job.getClass().getName() + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber());
System.out.println("start : " + key + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber()); System.out.println("start : " + key + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber());
this.taskMap.put(key, ot); this.taskMap.put(key, ot);
/* /*
...@@ -100,7 +99,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager ...@@ -100,7 +99,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager
this.jobTimer.schedule(ot, ot.delay); this.jobTimer.schedule(ot, ot.delay);
} }
else else
logger.severe("Got invalid task"); System.err.println("Got invalid task");
} }
private void handleExecuteJob(ItcMessage msg) private void handleExecuteJob(ItcMessage msg)
...@@ -118,8 +117,8 @@ public class OfflineTaskManager extends MultiThreadQueueManager ...@@ -118,8 +117,8 @@ public class OfflineTaskManager extends MultiThreadQueueManager
if (ot.enoughTimeToRun()) if (ot.enoughTimeToRun())
{ {
logger.info("execute : " + ot.job.getClass().getName() + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber()); // logger.info("execute : " + ot.job.getClass().getName() + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber());
//System.out.println("execute : " + key + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber()); System.out.println("execute : " + ot.job.getClass().getName() + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber());
ot.runJob(); ot.runJob();
if (!ot.resolveContinue()) if (!ot.resolveContinue())
{ {
...@@ -130,7 +129,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager ...@@ -130,7 +129,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager
} }
} }
else else
logger.info("not enough time to execute : " + ot.job.getClass().getName() + " on thread: " + this.getThreadNumber()); System.out.println("not enough time to execute : " + ot.job.getClass().getName() + " on thread: " + this.getThreadNumber());
} }
} }
...@@ -146,7 +145,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager ...@@ -146,7 +145,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager
String key = (String)msg.getExtraMsgObj(); String key = (String)msg.getExtraMsgObj();
if (key != null) if (key != null)
{ {
logger.info("removing task for: " + key + " from hash" + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber()); System.out.println("removing task for: " + key + " from hash" + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber());
//System.out.println("removing task for: " + key + " from hash" + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber()); //System.out.println("removing task for: " + key + " from hash" + ", sent from: " + msg.getFromSender() + " on thread: " + this.getThreadNumber());
OfflineTask ot = this.taskMap.remove(key); OfflineTask ot = this.taskMap.remove(key);
if (ot != null) if (ot != null)
...@@ -218,7 +217,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager ...@@ -218,7 +217,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager
return this.sendJob(START_TASK, ot, key, queueNum,MY_NAME); return this.sendJob(START_TASK, ot, key, queueNum,MY_NAME);
} }
else else
logger.warning("invalid params"); System.out.println("pushTask: invalid params");
return false; return false;
} }
......
...@@ -3,7 +3,7 @@ package timerManager; ...@@ -3,7 +3,7 @@ package timerManager;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import common.Log4jHandler; //import common.Log4jHandler;
import otm.IOfflineTaskJob; import otm.IOfflineTaskJob;
import otm.OfflineTaskManager; import otm.OfflineTaskManager;
...@@ -32,7 +32,7 @@ public class TimerManager ...@@ -32,7 +32,7 @@ public class TimerManager
@Override @Override
public void run() public void run()
{ {
logger.info("TimerManagerTask.run: " + key + ",tag: " + tag); System.out.println("TimerManagerTask.run: " + key + ",tag: " + tag);
if (listener != null) if (listener != null)
listener.timerElapsed(key, tag, appData); listener.timerElapsed(key, tag, appData);
...@@ -47,7 +47,7 @@ public class TimerManager ...@@ -47,7 +47,7 @@ public class TimerManager
public void jobCancelled() public void jobCancelled()
{ {
logger.info("TimerManagerTask.jobCancelled: " + key + ",tag: " + tag); System.out.println("TimerManagerTask.jobCancelled: " + key + ",tag: " + tag);
if (listener != null) if (listener != null)
listener.timerStopped(key, tag); listener.timerStopped(key, tag);
} }
...@@ -69,7 +69,7 @@ public class TimerManager ...@@ -69,7 +69,7 @@ public class TimerManager
} }
private final static Log4jHandler logger = new Log4jHandler(TimerManager.class.getName()); // private final static Log4jHandler logger = new Log4jHandler(TimerManager.class.getName());
ITimerEventListener listener = null; ITimerEventListener listener = null;
OfflineTaskManager offlineTaskManager = null; OfflineTaskManager offlineTaskManager = null;
...@@ -93,8 +93,8 @@ public class TimerManager ...@@ -93,8 +93,8 @@ public class TimerManager
{ {
tag = (tag != null) ? tag :NO_TAG; tag = (tag != null) ? tag :NO_TAG;
key = (key != null) ? key : UUID.randomUUID().toString(); key = (key != null) ? key : UUID.randomUUID().toString();
logger.info("starting timer for: " + key + ", tag: " + tag + ", duration: " + String.valueOf(toMilliSeconds)); System.out.println("starting timer for: " + key + ", tag: " + tag + ", duration: " + String.valueOf(toMilliSeconds));
TimerManagerTask timerManagerTask = new TimerManagerTask(key,tag,appData); TimerManagerTask timerManagerTask = new TimerManagerTask(key,tag,appData);
if(offlineTaskManager.pushTask(key, timerManagerTask, toMilliSeconds, 0, 0)) if(offlineTaskManager.pushTask(key, timerManagerTask, toMilliSeconds, 0, 0))
return key; return key;
...@@ -113,8 +113,8 @@ public class TimerManager ...@@ -113,8 +113,8 @@ public class TimerManager
{ {
tag = (tag != null) ? tag :NO_TAG; tag = (tag != null) ? tag :NO_TAG;
key = (key != null) ? key : UUID.randomUUID().toString(); key = (key != null) ? key : UUID.randomUUID().toString();
logger.info("starting timer for: " + key + ", tag: " + tag + ", duration: " + String.valueOf(toMilliSeconds)); System.out.println("starting timer for: " + key + ", tag: " + tag + ", duration: " + String.valueOf(toMilliSeconds));
TimerManagerTask timerManagerTask = new TimerManagerPeriodicTask(key,tag,appData); TimerManagerTask timerManagerTask = new TimerManagerPeriodicTask(key,tag,appData);
if (offlineTaskManager.pushTask(key, timerManagerTask,0, toMilliSeconds, -1)) if (offlineTaskManager.pushTask(key, timerManagerTask,0, toMilliSeconds, -1))
return key; return key;
...@@ -127,7 +127,7 @@ public class TimerManager ...@@ -127,7 +127,7 @@ public class TimerManager
*/ */
public void stopTimer(String key) public void stopTimer(String key)
{ {
logger.info("cancel timer for: " + key); System.out.println("cancel timer for: " + key);
offlineTaskManager.cancelTask(key); offlineTaskManager.cancelTask(key);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment