Merge "Issue #851 change date formatters to use ThreadLocal instead of synchronized blocks." into development
Former-commit-id:0ee07efae3
[formerly4f64038c78
] [formerly97a1d083cd
] [formerly8631b64e75
[formerly97a1d083cd
[formerly 4b7c1b1876f07de56c8f915d7c4a9c7707ccdf13]]] Former-commit-id:8631b64e75
Former-commit-id: 503c7d83973ae804ded15031b58be41631d56fed [formerlyc379c2f884
] Former-commit-id:96e3782774
This commit is contained in:
commit
e76f7f576a
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