3 This licence applies to all files in this repository unless otherwise specifically
4 stated inside of the file.
6 ---------------------------------------------------------------------------
7 Copyright (c) 2016 AT&T Intellectual Property
9 Licensed under the Apache License, Version 2.0 (the "License");
10 you may not use this file except in compliance with the License.
11 You may obtain a copy of the License at:
13 http://www.apache.org/licenses/LICENSE-2.0
15 Unless required by applicable law or agreed to in writing, software
16 distributed under the License is distributed on an "AS IS" BASIS,
17 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 See the License for the specific language governing permissions and
19 limitations under the License.
20 ---------------------------------------------------------------------------
26 import java.io.IOException;
27 import java.net.InetAddress;
28 import java.net.UnknownHostException;
29 import java.security.SecureRandom;
30 public class MusicConnector {
32 //change this to point to relevant cluster
33 public String[] musicNodes;
35 public MusicConnector(String[] musicNodes){
36 this.musicNodes = musicNodes;
39 private String getMusicNodeIp(){
40 SecureRandom r = new SecureRandom();
41 int index = r.nextInt(musicNodes.length);
42 return musicNodes[index];
45 public String getMusicNodeURL(){
46 String musicurl = "http://"+getMusicNodeIp()+":8080/MUSIC/rest/v2";
50 public boolean isHostUp(String serverAddress) {
53 InetAddress inet = InetAddress.getByName(serverAddress);
54 isUp = inet.isReachable(1000);
55 } catch (UnknownHostException e) {
56 // TODO Auto-generated catch block
58 } catch (IOException e) {
59 // TODO Auto-generated catch block
66 private static String getMusicNodeIp(){
68 //return "54.224.168.13";
69 return bigSiteMusicNode;
71 serverAddress = agaveMusicNode;
72 while(isHostUp(serverAddress) != true)
73 serverAddress = toggle(serverAddress);