Commit 33a89921 by Amir Aharon

1.3.4 - remove Log4jHandler from JsonHandler and other utils

parent 9af8aaa0
### general utils
## 1.2.0: support PATCH method in http request
## 1.1.4: overriding config file properties with env
## 1.3.4
- remove Log4jHandler from JsonHandler and other utils
## 1.2.5
- support 'assumeContentBinary' flag
## 1.2.4
- support binary content in response
## 1.2.3:
- add "mavenLocal", for local repository. enables to check this dependency locally
- Handle correctly Exceptions in http requsts/responses
- support Encoding type (other than utf8) in http responses
## 1.2.4
- support binary content in response
## 1.2.5
- support 'assumeContentBinary' flag
\ No newline at end of file
## 1.2.0: support PATCH method in http request
## 1.1.4: overriding config file properties with env
group 'com.ipgallery.common'
version '1.3.3'
version '1.3.4'
apply plugin: 'java'
apply plugin: 'maven-publish'
......
......@@ -9,7 +9,7 @@ import java.io.IOException;
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();
static {
......@@ -23,7 +23,7 @@ public class JsonHandler {
objString = SORTED_MAPPER.writeValueAsString(obj);
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
logger.error("in getObjectAsJsonString", e);
System.err.println("in getObjectAsJsonString" + e);
}
return objString;
}
......
......@@ -11,7 +11,7 @@ import org.apache.commons.io.monitor.FileAlterationObserver;
*/
public class Log4jFileAlterationListenerImpl implements FileAlterationListener {
Log4jHandler logger = new Log4jHandler(Log4jFileAlterationListenerImpl.class.getName());
// Log4jHandler logger = new Log4jHandler(Log4jFileAlterationListenerImpl.class.getName());
/**
* {@inheritDoc}
......@@ -73,9 +73,9 @@ public class Log4jFileAlterationListenerImpl implements FileAlterationListener {
// logger.debug("----------> executable: " + file.canExecute());
try {
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) {
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;
import java.util.Map;
import java.util.Map.Entry;
import common.Log4jHandler;
//import common.Log4jHandler;
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;
Map<String, MultiThreadQueueManager> mtqmMap = new HashMap<String, MultiThreadQueueManager>();
......@@ -48,7 +48,7 @@ public class MultiThreadQueueHander
mtqmMap.put(name, mtqm);
}
else
logger.error("failed to start queue manager: " + name);
System.err.println("failed to start queue manager: " + name);
}
}
return mtqm;
......@@ -61,7 +61,7 @@ public class MultiThreadQueueHander
public synchronized void stop()
{
logger.warning("Stopping the managers...");
System.out.println("Stopping the managers...");
for (Entry<String, MultiThreadQueueManager> mtqmEntry : mtqmMap.entrySet())
{
if (mtqmEntry != null)
......@@ -69,7 +69,7 @@ public class MultiThreadQueueHander
mtqmEntry.getValue().stopManager();
}
}
logger.warning("Stopped all managers, clearing...");
System.out.println("Stopped all managers, clearing...");
mtqmMap.clear();
}
......
......@@ -7,7 +7,7 @@ import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import common.Log4jHandler;
//import common.Log4jHandler;
/**
* this manager holds thread that handle async jobs
......@@ -22,7 +22,7 @@ public class MultiThreadQueueManager
{
protected List<JobThread> mJobThreadArray = 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 mQueueSize = 0;
protected int mReceiveBulkSize = 0;
......@@ -62,7 +62,7 @@ public class MultiThreadQueueManager
}
} catch (Exception e)
{
logger.info(e.toString());
System.out.println(e.toString());
}
}
......@@ -83,7 +83,7 @@ public class MultiThreadQueueManager
{
Runnable runJob = (Runnable) msg.getMsgObj();
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);
runJob.run();
......@@ -132,7 +132,7 @@ public class MultiThreadQueueManager
public boolean stopManager()
{
logger.warning("Stopping the threads...");
System.out.println("Stopping the threads...");
for (JobThread thr : mJobThreadArray)
{
if (thr != null)
......@@ -144,13 +144,13 @@ public class MultiThreadQueueManager
thr.join(1000);
thr = null;
} catch (InterruptedException e)
{
logger.severe(e.toString());
{
System.err.println(e.toString());
}
}
}
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;
}
......
......@@ -11,7 +11,7 @@ import java.util.Set;
import java.util.Timer;
import java.util.concurrent.atomic.AtomicInteger;
import common.Log4jHandler;
//import common.Log4jHandler;
import mtqm.MultiThreadQueueManager;
/**
......@@ -26,7 +26,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager
private final static int CANCEL_TASK = 2;
private final static int EXECUTE_JOB = 3;
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;
AtomicInteger currentThread = new AtomicInteger(0);
......@@ -88,7 +88,6 @@ public class OfflineTaskManager extends MultiThreadQueueManager
OfflineTask ot = (OfflineTask)msg.getMsgObj();
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());
this.taskMap.put(key, ot);
/*
......@@ -100,7 +99,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager
this.jobTimer.schedule(ot, ot.delay);
}
else
logger.severe("Got invalid task");
System.err.println("Got invalid task");
}
private void handleExecuteJob(ItcMessage msg)
......@@ -118,8 +117,8 @@ public class OfflineTaskManager extends MultiThreadQueueManager
if (ot.enoughTimeToRun())
{
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());
// logger.info("execute : " + ot.job.getClass().getName() + ", 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();
if (!ot.resolveContinue())
{
......@@ -130,7 +129,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager
}
}
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
String key = (String)msg.getExtraMsgObj();
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());
OfflineTask ot = this.taskMap.remove(key);
if (ot != null)
......@@ -218,7 +217,7 @@ public class OfflineTaskManager extends MultiThreadQueueManager
return this.sendJob(START_TASK, ot, key, queueNum,MY_NAME);
}
else
logger.warning("invalid params");
System.out.println("pushTask: invalid params");
return false;
}
......
......@@ -3,7 +3,7 @@ package timerManager;
import java.util.Map;
import java.util.UUID;
import common.Log4jHandler;
//import common.Log4jHandler;
import otm.IOfflineTaskJob;
import otm.OfflineTaskManager;
......@@ -32,7 +32,7 @@ public class TimerManager
@Override
public void run()
{
logger.info("TimerManagerTask.run: " + key + ",tag: " + tag);
System.out.println("TimerManagerTask.run: " + key + ",tag: " + tag);
if (listener != null)
listener.timerElapsed(key, tag, appData);
......@@ -47,7 +47,7 @@ public class TimerManager
public void jobCancelled()
{
logger.info("TimerManagerTask.jobCancelled: " + key + ",tag: " + tag);
System.out.println("TimerManagerTask.jobCancelled: " + key + ",tag: " + tag);
if (listener != null)
listener.timerStopped(key, tag);
}
......@@ -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;
OfflineTaskManager offlineTaskManager = null;
......@@ -93,8 +93,8 @@ public class TimerManager
{
tag = (tag != null) ? tag :NO_TAG;
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);
if(offlineTaskManager.pushTask(key, timerManagerTask, toMilliSeconds, 0, 0))
return key;
......@@ -113,8 +113,8 @@ public class TimerManager
{
tag = (tag != null) ? tag :NO_TAG;
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);
if (offlineTaskManager.pushTask(key, timerManagerTask,0, toMilliSeconds, -1))
return key;
......@@ -127,7 +127,7 @@ public class TimerManager
*/
public void stopTimer(String key)
{
logger.info("cancel timer for: " + key);
System.out.println("cancel timer for: " + 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