SAMZA-1268: Javadoc cleanup for public APIs for 0.13 release
[samza.git] / samza-api / src / main / java / org / apache / samza / task / TaskContext.java
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
20 package org.apache.samza.task;
21
22 import org.apache.samza.container.SamzaContainerContext;
23 import org.apache.samza.container.TaskName;
24 import org.apache.samza.metrics.MetricsRegistry;
25 import org.apache.samza.system.SystemStreamPartition;
26
27 import java.util.Set;
28
29 /**
30 * A TaskContext provides resources about the {@link org.apache.samza.task.StreamTask}, particularly during
31 * initialization in an {@link org.apache.samza.task.InitableTask}.
32 */
33 public interface TaskContext {
34 MetricsRegistry getMetricsRegistry();
35
36 Set<SystemStreamPartition> getSystemStreamPartitions();
37
38 Object getStore(String name);
39
40 TaskName getTaskName();
41
42 SamzaContainerContext getSamzaContainerContext();
43
44 /**
45 * Set the starting offset for the given {@link org.apache.samza.system.SystemStreamPartition}. Offsets
46 * can only be set for a {@link org.apache.samza.system.SystemStreamPartition} assigned to this task
47 * (as returned by {@link #getSystemStreamPartitions()}); trying to set the offset for any other partition
48 * will have no effect.
49 *
50 * NOTE: this feature is experimental, and the API may change in a future release.
51 *
52 * @param ssp {@link org.apache.samza.system.SystemStreamPartition} whose offset should be set
53 * @param offset to set for the given {@link org.apache.samza.system.SystemStreamPartition}
54 *
55 */
56 void setStartingOffset(SystemStreamPartition ssp, String offset);
57
58 /**
59 * Sets the user-defined context.
60 *
61 * @param context the user-defined context to set
62 */
63 default void setUserContext(Object context) { }
64
65 /**
66 * Gets the user-defined context.
67 *
68 * @return the user-defined context if set, else null
69 */
70 default Object getUserContext() {
71 return null;
72 }
73 }