19
19
20
20
package org .elasticsearch .cluster .metadata ;
21
21
22
- import com .carrotsearch .hppc .IntArrayList ;
22
+ import com .carrotsearch .hppc .LongArrayList ;
23
23
import com .carrotsearch .hppc .cursors .ObjectCursor ;
24
24
import com .carrotsearch .hppc .cursors .ObjectObjectCursor ;
25
25
import org .elasticsearch .Version ;
@@ -173,7 +173,7 @@ public static State fromString(String state) {
173
173
174
174
private final String index ;
175
175
private final long version ;
176
- private final int [] primaryTerms ;
176
+ private final long [] primaryTerms ;
177
177
178
178
private final State state ;
179
179
@@ -195,7 +195,7 @@ public static State fromString(String state) {
195
195
private final Version indexUpgradedVersion ;
196
196
private final org .apache .lucene .util .Version minimumCompatibleLuceneVersion ;
197
197
198
- private IndexMetaData (String index , long version , int [] primaryTerms , State state , Settings settings , ImmutableOpenMap <String , MappingMetaData > mappings , ImmutableOpenMap <String , AliasMetaData > aliases , ImmutableOpenMap <String , Custom > customs ) {
198
+ private IndexMetaData (String index , long version , long [] primaryTerms , State state , Settings settings , ImmutableOpenMap <String , MappingMetaData > mappings , ImmutableOpenMap <String , AliasMetaData > aliases , ImmutableOpenMap <String , Custom > customs ) {
199
199
Integer maybeNumberOfShards = settings .getAsInt (SETTING_NUMBER_OF_SHARDS , null );
200
200
if (maybeNumberOfShards == null ) {
201
201
throw new IllegalArgumentException ("must specify numberOfShards for index [" + index + "]" );
@@ -288,7 +288,7 @@ public long getVersion() {
288
288
* a primary shard is assigned after a full cluster restart (see {@link ShardRouting#initialize(java.lang.String, long)}
289
289
* or a replica shard is promoted to a primary (see {@link ShardRouting#moveToPrimary()}).
290
290
**/
291
- public int primaryTerm (int shardId ) {
291
+ public long primaryTerm (int shardId ) {
292
292
return this .primaryTerms [shardId ];
293
293
}
294
294
@@ -471,7 +471,7 @@ private static class IndexMetaDataDiff implements Diff<IndexMetaData> {
471
471
472
472
private final String index ;
473
473
private final long version ;
474
- private final int [] primaryTerms ;
474
+ private final long [] primaryTerms ;
475
475
private final State state ;
476
476
private final Settings settings ;
477
477
private final Diff <ImmutableOpenMap <String , MappingMetaData >> mappings ;
@@ -494,7 +494,7 @@ public IndexMetaDataDiff(StreamInput in) throws IOException {
494
494
version = in .readLong ();
495
495
state = State .fromId (in .readByte ());
496
496
settings = Settings .readSettingsFromStream (in );
497
- primaryTerms = in .readVIntArray ();
497
+ primaryTerms = in .readVLongArray ();
498
498
mappings = DiffableUtils .readImmutableOpenMapDiff (in , MappingMetaData .PROTO );
499
499
aliases = DiffableUtils .readImmutableOpenMapDiff (in , AliasMetaData .PROTO );
500
500
customs = DiffableUtils .readImmutableOpenMapDiff (in , new DiffableUtils .KeyedReader <Custom >() {
@@ -516,7 +516,7 @@ public void writeTo(StreamOutput out) throws IOException {
516
516
out .writeLong (version );
517
517
out .writeByte (state .id );
518
518
Settings .writeSettingsToStream (settings , out );
519
- out .writeVIntArray (primaryTerms );
519
+ out .writeVLongArray (primaryTerms );
520
520
mappings .writeTo (out );
521
521
aliases .writeTo (out );
522
522
customs .writeTo (out );
@@ -542,7 +542,7 @@ public IndexMetaData readFrom(StreamInput in) throws IOException {
542
542
builder .version (in .readLong ());
543
543
builder .state (State .fromId (in .readByte ()));
544
544
builder .settings (readSettingsFromStream (in ));
545
- builder .primaryTerms (in .readVIntArray ());
545
+ builder .primaryTerms (in .readVLongArray ());
546
546
int mappingsSize = in .readVInt ();
547
547
for (int i = 0 ; i < mappingsSize ; i ++) {
548
548
MappingMetaData mappingMd = MappingMetaData .PROTO .readFrom (in );
@@ -568,7 +568,7 @@ public void writeTo(StreamOutput out) throws IOException {
568
568
out .writeLong (version );
569
569
out .writeByte (state .id ());
570
570
writeSettingsToStream (settings , out );
571
- out .writeVIntArray (primaryTerms );
571
+ out .writeVLongArray (primaryTerms );
572
572
out .writeVInt (mappings .size ());
573
573
for (ObjectCursor <MappingMetaData > cursor : mappings .values ()) {
574
574
cursor .value .writeTo (out );
@@ -597,7 +597,7 @@ public static class Builder {
597
597
private String index ;
598
598
private State state = State .OPEN ;
599
599
private long version = 1 ;
600
- private int [] primaryTerms = null ;
600
+ private long [] primaryTerms = null ;
601
601
private Settings settings = Settings .Builder .EMPTY_SETTINGS ;
602
602
private final ImmutableOpenMap .Builder <String , MappingMetaData > mappings ;
603
603
private final ImmutableOpenMap .Builder <String , AliasMetaData > aliases ;
@@ -739,7 +739,7 @@ public Builder version(long version) {
739
739
* returns the primary term for the given shard.
740
740
* See {@link IndexMetaData#primaryTerm(int)} for more information.
741
741
*/
742
- public int primaryTerm (int shardId ) {
742
+ public long primaryTerm (int shardId ) {
743
743
if (primaryTerms == null ) {
744
744
initializePrimaryTerms ();
745
745
}
@@ -750,15 +750,15 @@ public int primaryTerm(int shardId) {
750
750
* sets the primary term for the given shard.
751
751
* See {@link IndexMetaData#primaryTerm(int)} for more information.
752
752
*/
753
- public Builder primaryTerm (int shardId , int primaryTerm ) {
753
+ public Builder primaryTerm (int shardId , long primaryTerm ) {
754
754
if (primaryTerms == null ) {
755
755
initializePrimaryTerms ();
756
756
}
757
757
this .primaryTerms [shardId ] = primaryTerm ;
758
758
return this ;
759
759
}
760
760
761
- private void primaryTerms (int [] primaryTerms ) {
761
+ private void primaryTerms (long [] primaryTerms ) {
762
762
this .primaryTerms = primaryTerms ;
763
763
}
764
764
@@ -767,7 +767,7 @@ private void initializePrimaryTerms() {
767
767
if (numberOfShards () < 0 ) {
768
768
throw new IllegalStateException ("you must set the number of shards before setting/reading primary terms" );
769
769
}
770
- primaryTerms = new int [numberOfShards ()];
770
+ primaryTerms = new long [numberOfShards ()];
771
771
}
772
772
773
773
@@ -912,10 +912,10 @@ public static IndexMetaData fromXContent(XContentParser parser) throws IOExcepti
912
912
}
913
913
}
914
914
} else if (fieldEquals (Fields .PRIMARY_TERMS , currentFieldName )) {
915
- IntArrayList list = new IntArrayList ();
915
+ LongArrayList list = new LongArrayList ();
916
916
while ((token = parser .nextToken ()) != XContentParser .Token .END_ARRAY ) {
917
917
if (token == XContentParser .Token .VALUE_NUMBER ) {
918
- list .add (parser .intValue ());
918
+ list .add (parser .longValue ());
919
919
} else {
920
920
throw new IllegalStateException ("found a non-numeric value under [" + Fields .PRIMARY_TERMS .underscore () + "]" );
921
921
}
0 commit comments