Issue #851 change date formatters to use ThreadLocal instead of synchronized blocks.
Change-Id: I1d3818cf90d21d3cc725b9a83e55eb5068b7aa62 Former-commit-id:c2937d7303
[formerlye9f24e8660
] [formerly7c6686f2f4
] [formerlyb1650b6143
[formerly7c6686f2f4
[formerly 181fba1a75357aa39a54267c6df907075f4601dc]]] Former-commit-id:b1650b6143
Former-commit-id: 7e61eb27b9b666aa966565378d537d64b5825d69 [formerly6a3e6f599f
] Former-commit-id:4efd9149f7
This commit is contained in:
parent
5a58fc89bf
commit
701d77f90a
3 changed files with 36 additions and 50 deletions
|
@ -106,12 +106,17 @@ public abstract class AbstractParmManager implements IParmManager {
|
||||||
|
|
||||||
private static final int NOTIFICATION_THREADS = 4;
|
private static final int NOTIFICATION_THREADS = 4;
|
||||||
|
|
||||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
|
private static final ThreadLocal<SimpleDateFormat> dateFormat = new ThreadLocal<SimpleDateFormat>() {
|
||||||
DatabaseID.MODEL_TIME_FORMAT);
|
|
||||||
|
|
||||||
static {
|
@Override
|
||||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
protected SimpleDateFormat initialValue() {
|
||||||
}
|
SimpleDateFormat df = new SimpleDateFormat(
|
||||||
|
DatabaseID.MODEL_TIME_FORMAT);
|
||||||
|
df.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
return df;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
protected class ParmIDVis {
|
protected class ParmIDVis {
|
||||||
private ParmID pid;
|
private ParmID pid;
|
||||||
|
@ -478,9 +483,7 @@ public abstract class AbstractParmManager implements IParmManager {
|
||||||
if (string.length() - pos == 14) {
|
if (string.length() - pos == 14) {
|
||||||
try {
|
try {
|
||||||
dtg = string.substring(pos + 1);
|
dtg = string.substring(pos + 1);
|
||||||
synchronized (dateFormat) {
|
dateFormat.get().parse(dtg);
|
||||||
dateFormat.parse(dtg);
|
|
||||||
}
|
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,12 +59,17 @@ public class SmartInitRecordPK implements ISerializableObject, Serializable,
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
|
private static final ThreadLocal<SimpleDateFormat> dateFormat = new ThreadLocal<SimpleDateFormat>() {
|
||||||
DatabaseID.MODEL_TIME_FORMAT);
|
|
||||||
|
|
||||||
static {
|
@Override
|
||||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
protected SimpleDateFormat initialValue() {
|
||||||
}
|
SimpleDateFormat df = new SimpleDateFormat(
|
||||||
|
DatabaseID.MODEL_TIME_FORMAT);
|
||||||
|
df.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
return df;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
PENDING, RUNNING
|
PENDING, RUNNING
|
||||||
|
@ -189,9 +194,7 @@ public class SmartInitRecordPK implements ISerializableObject, Serializable,
|
||||||
tmp.append(initName);
|
tmp.append(initName);
|
||||||
tmp.append(" ValidTime: ");
|
tmp.append(" ValidTime: ");
|
||||||
if (validTime != null) {
|
if (validTime != null) {
|
||||||
synchronized (dateFormat) {
|
tmp.append(dateFormat.get().format(validTime));
|
||||||
tmp.append(dateFormat.format(validTime));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
tmp.append("null");
|
tmp.append("null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,12 +74,17 @@ public class DatabaseID implements Serializable, Comparable<DatabaseID>,
|
||||||
|
|
||||||
public static final String MODEL_TIME_FORMAT = "yyyyMMdd_HHmm";
|
public static final String MODEL_TIME_FORMAT = "yyyyMMdd_HHmm";
|
||||||
|
|
||||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
|
private static final ThreadLocal<SimpleDateFormat> dateFormat = new ThreadLocal<SimpleDateFormat>() {
|
||||||
MODEL_TIME_FORMAT);
|
|
||||||
|
|
||||||
static {
|
@Override
|
||||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
protected SimpleDateFormat initialValue() {
|
||||||
}
|
SimpleDateFormat df = new SimpleDateFormat(
|
||||||
|
DatabaseID.MODEL_TIME_FORMAT);
|
||||||
|
df.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
return df;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/** Denotes what type of database */
|
/** Denotes what type of database */
|
||||||
public enum DataType {
|
public enum DataType {
|
||||||
|
@ -150,14 +155,8 @@ public class DatabaseID implements Serializable, Comparable<DatabaseID>,
|
||||||
*/
|
*/
|
||||||
public DatabaseID(String siteId, DataType format, String dbType,
|
public DatabaseID(String siteId, DataType format, String dbType,
|
||||||
String modelName, Date modelTime) {
|
String modelName, Date modelTime) {
|
||||||
this.siteId = siteId;
|
this(siteId, format, dbType, modelName, dateFormat.get().format(
|
||||||
this.format = format;
|
modelTime));
|
||||||
this.dbType = dbType;
|
|
||||||
this.modelName = modelName;
|
|
||||||
synchronized (dateFormat) {
|
|
||||||
this.modelTime = dateFormat.format(modelTime);
|
|
||||||
}
|
|
||||||
encodeIdentifier();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,21 +232,6 @@ public class DatabaseID implements Serializable, Comparable<DatabaseID>,
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the filename for the database associated with this database ID
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String dbFilename() {
|
|
||||||
// TODO: Is this method necessary?
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String dbPathName() {
|
|
||||||
// TODO: Is this method necessary?
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this is a valid database identifier
|
* Returns true if this is a valid database identifier
|
||||||
*
|
*
|
||||||
|
@ -357,9 +341,7 @@ public class DatabaseID implements Serializable, Comparable<DatabaseID>,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
synchronized (dateFormat) {
|
dateFormat.get().parse(dtgString);
|
||||||
dateFormat.parse(dtgString);
|
|
||||||
}
|
|
||||||
modelTime = dtgString;
|
modelTime = dtgString;
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -497,9 +479,7 @@ public class DatabaseID implements Serializable, Comparable<DatabaseID>,
|
||||||
Date date = null;
|
Date date = null;
|
||||||
if (modelTime != null && !NO_MODEL_TIME.equalsIgnoreCase(modelTime)) {
|
if (modelTime != null && !NO_MODEL_TIME.equalsIgnoreCase(modelTime)) {
|
||||||
try {
|
try {
|
||||||
synchronized (dateFormat) {
|
date = dateFormat.get().parse(this.modelTime);
|
||||||
date = dateFormat.parse(this.modelTime);
|
|
||||||
}
|
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue