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.security.token.Token; 027 import org.apache.hadoop.service.AbstractService; 028 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity; 029 import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse; 030 import org.apache.hadoop.yarn.client.api.impl.TimelineClientImpl; 031 import org.apache.hadoop.yarn.exceptions.YarnException; 032 import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; 033 034 /** 035 * A client library that can be used to post some information in terms of a 036 * number of conceptual entities. 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 /** 071 * <p> 072 * Get a delegation token so as to be able to talk to the timeline server in a 073 * secure way. 074 * </p> 075 * 076 * @param renewer 077 * Address of the renewer who can renew these tokens when needed by 078 * securely talking to the timeline server 079 * @return a delegation token ({@link Token}) that can be used to talk to the 080 * timeline server 081 * @throws IOException 082 * @throws YarnException 083 */ 084 @Public 085 public abstract Token<TimelineDelegationTokenIdentifier> getDelegationToken( 086 String renewer) throws IOException, YarnException; 087 088 }