001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package org.apache.hadoop.yarn.client.api;
020
021 import java.io.IOException;
022
023 import org.apache.hadoop.classification.InterfaceAudience.Private;
024 import org.apache.hadoop.classification.InterfaceAudience.Public;
025 import org.apache.hadoop.classification.InterfaceStability.Unstable;
026 import org.apache.hadoop.service.AbstractService;
027 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
028 import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
029 import org.apache.hadoop.yarn.client.api.impl.TimelineClientImpl;
030 import org.apache.hadoop.yarn.exceptions.YarnException;
031
032 /**
033 * A client library that can be used to post some information in terms of a
034 * number of conceptual entities.
035 *
036 * @See Entity
037 */
038 @Public
039 @Unstable
040 public abstract class TimelineClient extends AbstractService {
041
042 @Public
043 public static TimelineClient createTimelineClient() {
044 TimelineClient client = new TimelineClientImpl();
045 return client;
046 }
047
048 @Private
049 protected TimelineClient(String name) {
050 super(name);
051 }
052
053 /**
054 * <p>
055 * Send the information of a number of conceptual entities to the timeline
056 * server. It is a blocking API. The method will not return until it gets the
057 * response from the timeline server.
058 * </p>
059 *
060 * @param entities
061 * the collection of {@link TimelineEntity}
062 * @return the error information if the sent entities are not correctly stored
063 * @throws IOException
064 * @throws YarnException
065 */
066 @Public
067 public abstract TimelinePutResponse putEntities(
068 TimelineEntity... entities) throws IOException, YarnException;
069
070 }