use of com.yahoo.dba.perf.myperf.db.UserDBConnections in project mysql_perf_analyzer by yahoo.
the class LogoutController method handleRequestImpl.
@Override
protected ModelAndView handleRequestImpl(HttpServletRequest req, HttpServletResponse resp) throws Exception {
HttpSession sess = req.getSession();
//do we have session
if (sess != null) {
UserDBConnections conns = UserDBConnections.class.cast(sess.getAttribute("UserDBConnections"));
sess.removeAttribute("UserDBConnections");
sess.invalidate();
//make it async.
new Thread(new LogoutCleaner(conns)).start();
//TODO Add the thread handle for central process
}
ModelAndView mv = new ModelAndView(new RedirectView(this.getNosessView()));
return mv;
}
use of com.yahoo.dba.perf.myperf.db.UserDBConnections in project mysql_perf_analyzer by yahoo.
the class AlertScannerRunner method scan.
private void scan() {
conns = new UserDBConnections();
conns.setAppUser(appUser.getName());
conns.setFrameworkContext(frameworkContext);
int count = 0;
while (!dbqueue.isEmpty()) {
try {
DBInstanceInfo db = this.dbqueue.poll(1, TimeUnit.SECONDS);
count++;
if (db == null || !db.isAlertEnabled())
continue;
long startTime = System.currentTimeMillis();
scanHost(db);
//this.frameworkContext.getInstanceStatesManager().getStates(db.getDbid()).setLastScanTime(System.currentTimeMillis() - startTime);
} catch (Exception ex) {
logger.log(Level.WARNING, "Exception: scan loop", ex);
}
}
logger.info(Thread.currentThread() + " done scan alerts: " + count + " servers.");
}
use of com.yahoo.dba.perf.myperf.db.UserDBConnections in project mysql_perf_analyzer by yahoo.
the class GlobalVariableChangeScanTask method run.
@Override
public void run() {
Thread.currentThread().setName("GlobalVariableChangeScanTask");
conns = new UserDBConnections();
conns.setAppUser(appUser.getName());
conns.setFrameworkContext(context);
File root = new File(new File(this.context.getFileReposirtoryPath()), STORAGE_DIR);
//get all dbids
List<DBInstanceInfo> dbs = new ArrayList<DBInstanceInfo>();
for (Map.Entry<String, DBGroupInfo> e : context.getDbInfoManager().getClusters().entrySet()) {
DBGroupInfo g = e.getValue();
for (DBInstanceInfo i : g.getInstances()) {
dbs.add(i);
}
}
//now get current timestamp
sdf = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
for (//now we need scan for each db
DBInstanceInfo db : //now we need scan for each db
dbs) {
ConfigBlock cb = scanHost(db);
if (cb != null) {
updateConfigBlock(db, cb);
}
}
}
use of com.yahoo.dba.perf.myperf.db.UserDBConnections in project mysql_perf_analyzer by yahoo.
the class MetricScannerRunner method scan.
private void scan() {
running.set(true);
conns = new UserDBConnections();
conns.setAppUser(appUser.getName());
conns.setFrameworkContext(frameworkContext);
int count = 0;
while (!dbqueue.isEmpty() && running.get()) {
try {
DBInstanceInfo db = this.dbqueue.poll(1, TimeUnit.SECONDS);
count++;
if (db == null || !db.isMetricsEnabled())
continue;
long startTime = System.currentTimeMillis();
scanHost(db);
//record total scan time for each server
this.frameworkContext.getInstanceStatesManager().getStates(db.getDbid()).setLastScanTime(System.currentTimeMillis() - startTime);
} catch (Exception ex) {
logger.log(Level.WARNING, "Exception: scan loop", ex);
}
}
logger.info(Thread.currentThread() + " done scan metrics: " + count + " servers.");
}
use of com.yahoo.dba.perf.myperf.db.UserDBConnections in project mysql_perf_analyzer by yahoo.
the class WebAppUtil method closeDBConnection.
public static void closeDBConnection(HttpServletRequest req, DBConnectionWrapper conn, boolean hasError, boolean reuse) {
try {
//get session
HttpSession sess = req.getSession();
//get connection manager
UserDBConnections conns = UserDBConnections.class.cast(sess.getAttribute("UserDBConnections"));
//if none, we need add one
if (conns == null) {
//something wrong.
logger.info("Cannot find connection manager");
} else {
if (hasError)
conns.checkinConnectionOnError(conn);
else if (reuse)
conns.checkinConnection(conn);
else
conns.checkinConnectionAndClose(conn);
}
} catch (Throwable th) {
if (th instanceof RuntimeException)
throw RuntimeException.class.cast(th);
throw new RuntimeException(th);
}
}
Aggregations