31
31
import java .io .IOException ;
32
32
import java .text .DecimalFormatSymbols ;
33
33
import java .text .SimpleDateFormat ;
34
- import java .util .ArrayList ;
35
- import java .util .List ;
36
- import java .util .Locale ;
37
- import java .util .TimeZone ;
34
+ import java .util .*;
38
35
39
36
/**
40
37
* Versions:
53
50
*/
54
51
@ SuppressWarnings ("serial" )
55
52
public class OStorageConfiguration implements OSerializableStream {
56
- public static final ORecordId CONFIG_RID = new OImmutableRecordId (0 ,
57
- OClusterPositionFactory .INSTANCE .valueOf (0 ));
58
-
59
- public static final String DEFAULT_CHARSET = "UTF-8" ;
60
- private String charset = DEFAULT_CHARSET ;
61
- public static final int CURRENT_VERSION = 9 ;
62
- public static final int CURRENT_BINARY_FORMAT_VERSION = 11 ;
63
- public int version = -1 ;
64
- public String name ;
65
- public String schemaRecordId ;
66
- public String dictionaryRecordId ;
67
- public String indexMgrRecordId ;
68
- public String dateFormat = "yyyy-MM-dd" ;
69
- public String dateTimeFormat = "yyyy-MM-dd HH:mm:ss" ;
70
- public int binaryFormatVersion ;
71
- public OStorageSegmentConfiguration fileTemplate ;
72
- public List <OStorageClusterConfiguration > clusters = new ArrayList <OStorageClusterConfiguration >();
73
- public List <OStorageDataConfiguration > dataSegments = new ArrayList <OStorageDataConfiguration >();
74
- public OStorageTxConfiguration txSegment = new OStorageTxConfiguration ();
75
- public List <OStorageEntryConfiguration > properties = new ArrayList <OStorageEntryConfiguration >();
76
- protected transient OStorage storage ;
77
- private String localeLanguage = Locale .getDefault ().getLanguage ();
78
- private String localeCountry = Locale .getDefault ().getCountry ();
79
- private TimeZone timeZone = TimeZone .getDefault ();
80
- private transient Locale localeInstance ;
81
- private transient DecimalFormatSymbols unusualSymbols ;
82
- private String clusterSelection ;
83
- private int minimumClusters = 1 ;
53
+ public static final ORecordId CONFIG_RID = new OImmutableRecordId (0 ,
54
+ OClusterPositionFactory .INSTANCE .valueOf (0 ));
55
+
56
+ public static final String DEFAULT_CHARSET = "UTF-8" ;
57
+ private String charset = DEFAULT_CHARSET ;
58
+ public static final int CURRENT_VERSION = 9 ;
59
+ public static final int CURRENT_BINARY_FORMAT_VERSION = 11 ;
60
+ public volatile int version = -1 ;
61
+
62
+ public volatile String name ;
63
+ public volatile String schemaRecordId ;
64
+ public volatile String dictionaryRecordId ;
65
+ public volatile String indexMgrRecordId ;
66
+ public volatile String dateFormat = "yyyy-MM-dd" ;
67
+ public volatile String dateTimeFormat = "yyyy-MM-dd HH:mm:ss" ;
68
+ public volatile int binaryFormatVersion ;
69
+ public volatile OStorageSegmentConfiguration fileTemplate ;
70
+
71
+ public volatile List <OStorageClusterConfiguration > clusters = Collections
72
+ .synchronizedList (new ArrayList <OStorageClusterConfiguration >());
73
+ public final List <OStorageDataConfiguration > dataSegments = Collections
74
+ .synchronizedList (new ArrayList <OStorageDataConfiguration >());
75
+ public volatile OStorageTxConfiguration txSegment = new OStorageTxConfiguration ();
76
+ public final List <OStorageEntryConfiguration > properties = Collections
77
+ .synchronizedList (new ArrayList <OStorageEntryConfiguration >());
78
+
79
+ protected final transient OStorage storage ;
80
+ private volatile String localeLanguage = Locale .getDefault ().getLanguage ();
81
+ private volatile String localeCountry = Locale .getDefault ().getCountry ();
82
+ private volatile TimeZone timeZone = TimeZone .getDefault ();
83
+ private transient volatile Locale localeInstance ;
84
+ private transient volatile DecimalFormatSymbols unusualSymbols ;
85
+ private volatile String clusterSelection ;
86
+ private volatile int minimumClusters = 1 ;
84
87
85
88
public OStorageConfiguration (final OStorage iStorage ) {
86
89
storage = iStorage ;
@@ -186,7 +189,7 @@ public OSerializableStream fromStream(final byte[] iStream) throws OSerializatio
186
189
int size = Integer .parseInt (read (values [index ++]));
187
190
188
191
// PREPARE THE LIST OF CLUSTERS
189
- clusters = new ArrayList < OStorageClusterConfiguration >( size );
192
+ clusters . clear ( );
190
193
191
194
for (int i = 0 ; i < size ; ++i ) {
192
195
final int clusterId = Integer .parseInt (read (values [index ++]));
@@ -237,7 +240,7 @@ else if (clusterType.equals("d")) {
237
240
238
241
// PREPARE THE LIST OF DATA SEGS
239
242
size = Integer .parseInt (read (values [index ++]));
240
- dataSegments = new ArrayList < OStorageDataConfiguration >( size );
243
+ dataSegments . clear ( );
241
244
for (int i = 0 ; i < size ; ++i )
242
245
dataSegments .add (null );
243
246
@@ -260,7 +263,7 @@ else if (clusterType.equals("d")) {
260
263
read (values [index ++]), read (values [index ++]));
261
264
262
265
size = Integer .parseInt (read (values [index ++]));
263
- properties = new ArrayList < OStorageEntryConfiguration >( size );
266
+ properties . clear ( );
264
267
for (int i = 0 ; i < size ; ++i ) {
265
268
properties .add (new OStorageEntryConfiguration (read (values [index ++]), read (values [index ++])));
266
269
}
0 commit comments