|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license |
| 3 | + * agreements. See the NOTICE file distributed with this work for additional information regarding |
| 4 | + * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the |
| 5 | + * "License"); you may not use this file except in compliance with the License. You may obtain a |
| 6 | + * copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software distributed under the License |
| 11 | + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 12 | + * or implied. See the License for the specific language governing permissions and limitations under |
| 13 | + * the License. |
| 14 | + */ |
| 15 | + |
| 16 | +package org.apache.fluo.command; |
| 17 | + |
| 18 | +import java.io.File; |
| 19 | +import java.util.Collections; |
| 20 | +import java.util.List; |
| 21 | +import java.util.Objects; |
| 22 | + |
| 23 | +import com.google.common.base.Preconditions; |
| 24 | +import org.apache.curator.framework.CuratorFramework; |
| 25 | +import org.apache.fluo.api.config.FluoConfiguration; |
| 26 | +import org.apache.fluo.core.client.FluoAdminImpl; |
| 27 | +import org.apache.fluo.core.util.CuratorUtil; |
| 28 | + |
| 29 | +public class FluoStatus { |
| 30 | + |
| 31 | + public static void main(String[] args) throws Exception { |
| 32 | + if (args.length != 2) { |
| 33 | + System.err.println("Usage: FluoStatus <connectionPropsPath> <applicationName>"); |
| 34 | + System.exit(-1); |
| 35 | + } |
| 36 | + String connectionPropsPath = args[0]; |
| 37 | + String applicationName = args[1]; |
| 38 | + Objects.requireNonNull(connectionPropsPath); |
| 39 | + File connectionPropsFile = new File(connectionPropsPath); |
| 40 | + Preconditions.checkArgument(connectionPropsFile.exists(), connectionPropsPath |
| 41 | + + " does not exist"); |
| 42 | + |
| 43 | + FluoConfiguration config = new FluoConfiguration(connectionPropsFile); |
| 44 | + config.setApplicationName(applicationName); |
| 45 | + |
| 46 | + try (FluoAdminImpl admin = new FluoAdminImpl(config)) { |
| 47 | + if (!admin.zookeeperInitialized()) { |
| 48 | + System.out.println("NOT_FOUND"); |
| 49 | + } |
| 50 | + if (admin.applicationRunning()) { |
| 51 | + System.out.println("RUNNING"); |
| 52 | + } else { |
| 53 | + System.out.println("STOPPED"); |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments