lib/erlang/messenger/src/pm_client.erl in auser-poolparty-0.2.35 vs lib/erlang/messenger/src/pm_client.erl in auser-poolparty-0.2.36
- old
+ new
@@ -1,29 +1,37 @@
-module (pm_client).
-include_lib("../include/defines.hrl").
--define (SERVER, global:whereis_name(?MODULE)).
--export ([init_conn/0, send_cmd/1, reconfigure_cloud/0, get_load/1, get_live_nodes/0]).
+-export ([reconfigure_cloud/0, get_load/1, get_live_nodes/0, start/0]).
+-export ([run_cmd/1, fire_cmd/1]).
-export ([provision_orphan_running_servers/0]).
-export ([shutdown/0]).
% Run commands on the running master process
% erl -pa ./ebin/ -run pm_client get_load cpu -run init stop -noshell
% Connect to the master
-init_conn() -> net_adm:ping(?MASTER_LOCATION).
+start() ->
+ pong = net_adm:ping(?MASTER_LOCATION),
+ global:sync().
% Send the command Cmd to the pm_master process
-send_cmd(Cmd) ->
- init_conn(),
- pm_master:fire_cmd(Cmd).
+run_cmd(Cmd) ->
+ Out = pm_master:run_cmd(Cmd),
+ io:format("~p", [Out]),
+ Out.
+fire_cmd(Cmd) ->
+ Out = pm_master:fire_cmd(Cmd),
+ io:format("~p", [Out]),
+ Out.
% Reconfigure the cloud
-reconfigure_cloud() ->
- init_conn(),
- pm_master:reconfigure_cloud().
+reconfigure_cloud() -> pm_master:reconfigure_cloud().
% Get the load on the cloud of type Type
get_load(Type) ->
- init_conn(),
- pm_master:get_load(Type).
+ start(),
+ Load = pm_master:get_load(Type),
+ io:format("~p", [Load]),
+ Load.
+
% Check to see if there are servers that are unprovisioned
% And if there are, log in to them and start their messenger
% sending the live code on the master to them
provision_orphan_running_servers() ->
Instances = pm_cluster:any_new_servers(),
@@ -36,12 +44,10 @@
Instances
end.
% Get a list of the live nodes
get_live_nodes() ->
- init_conn(),
pm_cluster:get_live_nodes().
% Terminate the cloud messenger
% This sends a shutdown to the whole cloud
shutdown() ->
- init_conn(),
pm_master:shutdown_cloud().
\ No newline at end of file