1+ /*
2+ * Licensed to the Apache Software Foundation (ASF) under one
3+ * or more contributor license agreements. See the NOTICE file
4+ * distributed with this work for additional information
5+ * regarding copyright ownership. The ASF licenses this file
6+ * to you under the Apache License, Version 2.0 (the
7+ * "License"); you may not use this file except in compliance
8+ * with the License. You may obtain a copy of the License at
9+ *
10+ * http://www.apache.org/licenses/LICENSE-2.0
11+ *
12+ * Unless required by applicable law or agreed to in writing,
13+ * software distributed under the License is distributed on an
14+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+ * KIND, either express or implied. See the License for the
16+ * specific language governing permissions and limitations
17+ * under the License.
18+ */ /*
19+ * Licensed to the Apache Software Foundation (ASF) under one
20+ * or more contributor license agreements. See the NOTICE file
21+ * distributed with this work for additional information
22+ * regarding copyright ownership. The ASF licenses this file
23+ * to you under the Apache License, Version 2.0 (the
24+ * "License"); you may not use this file except in compliance
25+ * with the License. You may obtain a copy of the License at
26+ *
27+ * http://www.apache.org/licenses/LICENSE-2.0
28+ *
29+ * Unless required by applicable law or agreed to in writing,
30+ * software distributed under the License is distributed on an
31+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
32+ * KIND, either express or implied. See the License for the
33+ * specific language governing permissions and limitations
34+ * under the License.
35+ */ /*
36+ * Licensed to the Apache Software Foundation (ASF) under one
37+ * or more contributor license agreements. See the NOTICE file
38+ * distributed with this work for additional information
39+ * regarding copyright ownership. The ASF licenses this file
40+ * to you under the Apache License, Version 2.0 (the
41+ * "License"); you may not use this file except in compliance
42+ * with the License. You may obtain a copy of the License at
43+ *
44+ * http://www.apache.org/licenses/LICENSE-2.0
45+ *
46+ * Unless required by applicable law or agreed to in writing,
47+ * software distributed under the License is distributed on an
48+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
49+ * KIND, either express or implied. See the License for the
50+ * specific language governing permissions and limitations
51+ * under the License.
52+ */
53+ package org .apache .samza .startpoint ;
54+
55+ import java .io .IOException ;
56+ import java .util .HashMap ;
57+ import java .util .Map ;
58+ import org .apache .samza .container .TaskName ;
59+ import org .apache .samza .system .SystemStreamPartition ;
60+ import org .codehaus .jackson .JsonGenerator ;
61+ import org .codehaus .jackson .map .JsonSerializer ;
62+ import org .codehaus .jackson .map .SerializerProvider ;
63+
64+
65+ final class StartpointKeySerializer extends JsonSerializer <StartpointKey > {
66+ @ Override
67+ public void serialize (StartpointKey startpointKey , JsonGenerator jsonGenerator , SerializerProvider provider ) throws
68+ IOException {
69+ Map <String , Object > systemStreamPartitionMap = new HashMap <>();
70+ SystemStreamPartition systemStreamPartition = startpointKey .getSystemStreamPartition ();
71+ TaskName taskName = startpointKey .getTaskName ();
72+ systemStreamPartitionMap .put ("system" , systemStreamPartition .getSystem ());
73+ systemStreamPartitionMap .put ("stream" , systemStreamPartition .getStream ());
74+ systemStreamPartitionMap .put ("partition" , systemStreamPartition .getPartition ().getPartitionId ());
75+ if (taskName != null ) {
76+ systemStreamPartitionMap .put ("taskName" , taskName .getTaskName ());
77+ }
78+ jsonGenerator .writeObject (systemStreamPartitionMap );
79+ }
80+ }
0 commit comments