17
17
* under the License.
18
18
*/
19
19
20
- package org .elasticsearch .action .admin .indices .mapping .create ;
20
+ package org .elasticsearch .action .admin .indices .mapping .put ;
21
21
22
- import org .elasticsearch .action .ActionRequest ;
23
22
import org .elasticsearch .action .ActionRequestValidationException ;
23
+ import org .elasticsearch .action .support .master .MasterNodeOperationRequest ;
24
24
import org .elasticsearch .util .Required ;
25
25
import org .elasticsearch .util .TimeValue ;
26
- import org .elasticsearch .util .io .Streamable ;
27
26
28
27
import java .io .DataInput ;
29
28
import java .io .DataOutput ;
36
35
/**
37
36
* @author kimchy (Shay Banon)
38
37
*/
39
- public class CreateMappingRequest implements ActionRequest , Streamable {
38
+ public class PutMappingRequest extends MasterNodeOperationRequest {
40
39
41
40
private String [] indices ;
42
41
@@ -46,18 +45,18 @@ public class CreateMappingRequest implements ActionRequest, Streamable {
46
45
47
46
private TimeValue timeout = new TimeValue (10 , TimeUnit .SECONDS );
48
47
49
- CreateMappingRequest () {
48
+ PutMappingRequest () {
50
49
}
51
50
52
- public CreateMappingRequest (String ... indices ) {
51
+ public PutMappingRequest (String ... indices ) {
53
52
this .indices = indices ;
54
53
}
55
54
56
- public CreateMappingRequest (String index , String mappingType , String mappingSource ) {
55
+ public PutMappingRequest (String index , String mappingType , String mappingSource ) {
57
56
this (new String []{index }, mappingType , mappingSource );
58
57
}
59
58
60
- public CreateMappingRequest (String [] indices , String mappingType , String mappingSource ) {
59
+ public PutMappingRequest (String [] indices , String mappingType , String mappingSource ) {
61
60
this .indices = indices ;
62
61
this .mappingType = mappingType ;
63
62
this .mappingSource = mappingSource ;
@@ -71,12 +70,7 @@ public CreateMappingRequest(String[] indices, String mappingType, String mapping
71
70
return validationException ;
72
71
}
73
72
74
- @ Override public boolean listenerThreaded () {
75
- // we don't really care about this...
76
- return true ;
77
- }
78
-
79
- @ Override public CreateMappingRequest listenerThreaded (boolean threadedListener ) {
73
+ @ Override public PutMappingRequest listenerThreaded (boolean threadedListener ) {
80
74
return this ;
81
75
}
82
76
@@ -92,7 +86,7 @@ String type() {
92
86
* The type of the mappings. Not required since it can be defined explicitly within the mapping source.
93
87
* If it is not defined within the mapping source, then it is required.
94
88
*/
95
- public CreateMappingRequest type (String mappingType ) {
89
+ public PutMappingRequest type (String mappingType ) {
96
90
this .mappingType = mappingType ;
97
91
return this ;
98
92
}
@@ -101,7 +95,7 @@ String mappingSource() {
101
95
return mappingSource ;
102
96
}
103
97
104
- @ Required public CreateMappingRequest mappingSource (String mappingSource ) {
98
+ @ Required public PutMappingRequest mappingSource (String mappingSource ) {
105
99
this .mappingSource = mappingSource ;
106
100
return this ;
107
101
}
@@ -110,12 +104,13 @@ TimeValue timeout() {
110
104
return timeout ;
111
105
}
112
106
113
- public CreateMappingRequest timeout (TimeValue timeout ) {
107
+ public PutMappingRequest timeout (TimeValue timeout ) {
114
108
this .timeout = timeout ;
115
109
return this ;
116
110
}
117
111
118
112
@ Override public void readFrom (DataInput in ) throws IOException , ClassNotFoundException {
113
+ super .readFrom (in );
119
114
indices = new String [in .readInt ()];
120
115
for (int i = 0 ; i < indices .length ; i ++) {
121
116
indices [i ] = in .readUTF ();
@@ -128,6 +123,7 @@ public CreateMappingRequest timeout(TimeValue timeout) {
128
123
}
129
124
130
125
@ Override public void writeTo (DataOutput out ) throws IOException {
126
+ super .writeTo (out );
131
127
if (indices == null ) {
132
128
out .writeInt (0 );
133
129
} else {
0 commit comments