You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2013/12/17 23:46:35 UTC
svn commit: r1551747 - in /ofbiz/branches/release11.04: ./
framework/entity/dtd/entitymodel.xsd
framework/entity/src/org/ofbiz/entity/util/SequenceUtil.java
Author: jleroux
Date: Tue Dec 17 22:46:34 2013
New Revision: 1551747
URL: http://svn.apache.org/r1551747
Log:
"Applied fix from trunk for revision: 1551744 "
------------------------------------------------------------------------
r1551744 | jleroux | 2013-12-17 23:45:20 +0100 (mar. 17 déc. 2013) | 7 lignes
A slightly modified patch from Leon for "sequence-bank-size attributes does not work anymore" https://issues.apache.org/jira/browse/OFBIZ-5429
No matter how I set "sequence-bank-size" for an entity (in my example, its "EntityAuditLog"), the bank size is always default value "10".
It seems that this feature was lost by a serials update of revision 922724 to 922733 submitted by doogie.
jleroux: This thread http://markmail.org/message/ifosqek74gqtv7fz trace the root cause
Leon's fix is safe from a concurrency perspective. I just added a check on SequenceBank.maxBankSize and put some doc in the XSD
------------------------------------------------------------------------
Modified:
ofbiz/branches/release11.04/ (props changed)
ofbiz/branches/release11.04/framework/entity/dtd/entitymodel.xsd
ofbiz/branches/release11.04/framework/entity/src/org/ofbiz/entity/util/SequenceUtil.java
Propchange: ofbiz/branches/release11.04/
------------------------------------------------------------------------------
Merged /ofbiz/trunk:r1551744
Modified: ofbiz/branches/release11.04/framework/entity/dtd/entitymodel.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/entity/dtd/entitymodel.xsd?rev=1551747&r1=1551746&r2=1551747&view=diff
==============================================================================
--- ofbiz/branches/release11.04/framework/entity/dtd/entitymodel.xsd (original)
+++ ofbiz/branches/release11.04/framework/entity/dtd/entitymodel.xsd Tue Dec 17 22:46:34 2013
@@ -86,7 +86,14 @@ under the License.
<xs:attribute name="package-name" type="xs:string" use="required"/>
<xs:attribute name="default-resource-name" type="xs:string"/>
<xs:attribute name="dependent-on" type="xs:string"/>
- <xs:attribute name="sequence-bank-size" type="xs:string"/>
+ <xs:attribute name="sequence-bank-size" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ The 10 default value is defined in the SequenceBank class by the defaultBankSize constant.
+ Can't be more than 5000 which is defined by the maxBankSize constant.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="enable-lock" default="false" type="boolean"/>
<xs:attribute name="no-auto-stamp" default="false" type="boolean"/>
<xs:attribute name="never-cache" default="false" type="boolean"/>
@@ -463,7 +470,14 @@ under the License.
<xs:attribute name="entity-name" type="xs:string" use="required"/>
<xs:attribute name="default-resource-name" type="xs:string"/>
<xs:attribute name="dependent-on" type="xs:string"/>
- <xs:attribute name="sequence-bank-size" type="xs:string"/>
+ <xs:attribute name="sequence-bank-size" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ The 10 default value is defined in the SequenceBank class by the defaultBankSize constant.
+ Can't be more than 5000 which is defined by the maxBankSize constant.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="enable-lock" type="boolean"/>
<xs:attribute name="no-auto-stamp" type="boolean"/>
<xs:attribute name="never-cache" type="boolean"/>
Modified: ofbiz/branches/release11.04/framework/entity/src/org/ofbiz/entity/util/SequenceUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/entity/src/org/ofbiz/entity/util/SequenceUtil.java?rev=1551747&r1=1551746&r2=1551747&view=diff
==============================================================================
--- ofbiz/branches/release11.04/framework/entity/src/org/ofbiz/entity/util/SequenceUtil.java (original)
+++ ofbiz/branches/release11.04/framework/entity/src/org/ofbiz/entity/util/SequenceUtil.java Tue Dec 17 22:46:34 2013
@@ -48,7 +48,6 @@ public class SequenceUtil {
private final Map<String, SequenceBank> sequences = new Hashtable<String, SequenceBank>();
private final GenericHelperInfo helperInfo;
- private final long bankSize;
private final String tableName;
private final String nameColName;
private final String idColName;
@@ -74,11 +73,6 @@ public class SequenceUtil {
throw new IllegalArgumentException("Could not find the field definition for the sequence id field " + idFieldName);
}
this.idColName = idField.getColName();
- long bankSize = SequenceBank.defaultBankSize;
- if (seqEntity.getSequenceBankSize() != null) {
- bankSize = seqEntity.getSequenceBankSize().longValue();
- }
- this.bankSize = bankSize;
clustered = delegator.useDistributedCacheClear() || "Y".equals(UtilProperties.getPropertyValue("general.properties", "clustered"));
}
@@ -104,7 +98,12 @@ public class SequenceUtil {
synchronized(this) {
bank = sequences.get(seqName);
if (bank == null) {
- bank = new SequenceBank(seqName);
+ long bankSize = SequenceBank.defaultBankSize;
+ if (seqModelEntity != null && seqModelEntity.getSequenceBankSize() != null) {
+ bankSize = seqModelEntity.getSequenceBankSize().longValue();
+ if (bankSize > SequenceBank.maxBankSize) bankSize = SequenceBank.maxBankSize;
+ }
+ bank = new SequenceBank(seqName, bankSize);
sequences.put(seqName, bank);
}
}
@@ -124,11 +123,13 @@ public class SequenceUtil {
private long curSeqId;
private long maxSeqId;
private final String seqName;
+ private final long bankSize;
- private SequenceBank(String seqName) {
+ private SequenceBank(String seqName, long bankSize) {
this.seqName = seqName;
curSeqId = 0;
maxSeqId = 0;
+ this.bankSize = bankSize;
fillBank(1);
}
@@ -167,7 +168,7 @@ public class SequenceUtil {
// no need to get a new bank, SeqIds available
if ((curSeqId + stagger) <= maxSeqId) return;
- long bankSize = SequenceUtil.this.bankSize;
+ long bankSize = this.bankSize;
if (stagger > 1) {
// NOTE: could use staggerMax for this, but if that is done it would be easier to guess a valid next id without a brute force attack
bankSize = stagger * defaultBankSize;