@@ -93,19 +93,27 @@ public String getType() {
93
93
94
94
@ Override
95
95
public String generateBlobFileName () {
96
- // 123456789012_test-cluster/cluster-state/dsgYj10Nkso7/manifest/manifest__<inverted_term>__<inverted_version>__C/P__<inverted__timestamp>__
97
- // <codec_version>
98
- String blobFileName = String .join (
99
- DELIMITER ,
100
- MANIFEST ,
101
- RemoteStoreUtils .invertLong (clusterMetadataManifest .getClusterTerm ()),
102
- RemoteStoreUtils .invertLong (clusterMetadataManifest .getStateVersion ()),
103
- (clusterMetadataManifest .isCommitted () ? COMMITTED : PUBLISHED ),
104
- RemoteStoreUtils .invertLong (System .currentTimeMillis ()),
105
- String .valueOf (clusterMetadataManifest .getCodecVersion ())
106
- // Keep the codec version at last place only, during we read last place to determine codec version.
107
- );
108
- this .blobFileName = blobFileName ;
96
+ if (blobFileName != null ) {
97
+ return blobFileName ;
98
+ }
99
+ // filename is something like: manifest__<inverted_term>__<inverted_version>__C/P__<inverted__timestamp>__<codec_version>
100
+ if (clusterMetadataManifest != null ) {
101
+ this .blobFileName = String .join (
102
+ DELIMITER ,
103
+ MANIFEST ,
104
+ RemoteStoreUtils .invertLong (clusterMetadataManifest .getClusterTerm ()),
105
+ RemoteStoreUtils .invertLong (clusterMetadataManifest .getStateVersion ()),
106
+ (clusterMetadataManifest .isCommitted () ? COMMITTED : PUBLISHED ),
107
+ RemoteStoreUtils .invertLong (System .currentTimeMillis ()),
108
+ String .valueOf (clusterMetadataManifest .getCodecVersion ())
109
+ // Keep the codec version at last place only, during we read last place to determine codec version.
110
+ );
111
+ } else {
112
+ String [] pathTokens = getBlobPathTokens ();
113
+ assert pathTokens != null : "path tokens must not be null" ;
114
+ assert pathTokens .length > 0 : "path tokens must have at least one segment" ;
115
+ this .blobFileName = pathTokens [pathTokens .length - 1 ];
116
+ }
109
117
return blobFileName ;
110
118
}
111
119
@@ -131,16 +139,17 @@ public ClusterMetadataManifest deserialize(final InputStream inputStream) throws
131
139
return blobStoreFormat .deserialize (blobName , getNamedXContentRegistry (), Streams .readFully (inputStream ));
132
140
}
133
141
134
- private int getManifestCodecVersion () {
142
+ // package private for testing
143
+ int getManifestCodecVersion () {
135
144
assert blobName != null ;
136
- String [] splitName = blobName .split (DELIMITER );
145
+ String [] splitName = generateBlobFileName () .split (DELIMITER );
137
146
if (splitName .length == SPLITTED_MANIFEST_FILE_LENGTH ) {
138
147
return Integer .parseInt (splitName [splitName .length - 1 ]); // Last value would be codec version.
139
148
} else if (splitName .length < SPLITTED_MANIFEST_FILE_LENGTH ) { // Where codec is not part of file name, i.e. default codec version 0
140
149
// is used.
141
150
return ClusterMetadataManifest .CODEC_V0 ;
142
151
} else {
143
- throw new IllegalArgumentException ("Manifest file name is corrupted" );
152
+ throw new IllegalArgumentException ("Manifest file name is corrupted : " + blobName );
144
153
}
145
154
}
146
155
0 commit comments