1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 *******************************************************************************/
22 package com.att.nsa.mr.tools;
24 import java.util.Collection;
25 import java.util.LinkedList;
27 import com.att.nsa.apiClient.http.HttpClient;
28 import com.att.nsa.apiClient.http.HttpTracer;
29 import com.att.nsa.cmdtool.CommandContext;
30 import com.att.nsa.mr.client.MRClient;
32 public class MRCommandContext implements CommandContext
34 public MRCommandContext ()
39 fCluster = new LinkedList<String> ();
40 fCluster.add ( "localhost" );
44 public void requestShutdown ()
50 public boolean shouldContinue ()
55 public void setAuth ( String key, String pwd ) { fApiKey = key; fApiPwd = pwd; }
56 public void clearAuth () { setAuth(null,null); }
58 public boolean checkClusterReady ()
60 return ( fCluster.isEmpty());
63 public Collection<String> getCluster ()
65 return new LinkedList<String> ( fCluster );
68 public void clearCluster ()
73 public void addClusterHost ( String host )
75 fCluster.add ( host );
78 public String getApiKey () { return fApiKey; }
79 public String getApiPwd () { return fApiPwd; }
81 public void useTracer ( HttpTracer t )
85 public void noTracer () { fTracer = null; }
87 public void applyTracer ( MRClient cc )
89 if ( cc instanceof HttpClient && fTracer != null )
91 ((HttpClient)cc).installTracer ( fTracer );
95 private boolean fShutdown;
96 private String fApiKey;
97 private String fApiPwd;
98 private final LinkedList<String> fCluster;
99 private HttpTracer fTracer = null;