Skip to content
This repository has been archived by the owner on Mar 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #188 from claudio4j/HAL-998
Browse files Browse the repository at this point in the history
HAL-998 - Add ability to reload a host in domain mode
  • Loading branch information
hpehl committed May 20, 2016
2 parents 2ee9dd2 + ca1f2a0 commit 2c4c5f3
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ public interface UIConstants extends Constants {
String reason();
String reloadServerGroup();
String reloadServerNow();
String reloadHost();
String remoteSocketDescription();
String removeProfile();
String replace_me();
Expand All @@ -434,6 +435,7 @@ public interface UIConstants extends Constants {
String resolveExpressionValues();
String resource_already_exists();
String restartServerGroup();
String restartHost();
String resume();
String resumeServerGroup();
String runAs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ properties_global_desc=These properties are available throughout the configurati
reason=Reason
reloadServerGroup=Reload Server Group
reloadServerNow=Reload server(s) now\!
reloadHost=Reload Host
remoteSocketDescription=Configuration information for a, remote destination, outbound socket binding.
removeProfile=Remove Profile
replaceDeployment=Replace Deployment
Expand All @@ -403,6 +404,7 @@ resolveExpressionValues=Resolve Expression Values
resolvedValue=Resolved Value
resource_already_exists=Resource already exists
restartServerGroup=Restart Server Group
restartHost=Restart Host
resume=Resume
resumeServerGroup=Resume Server Group
runAs=Run as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ public interface UIMessages extends Messages {
String verify_datasource_successful_message(String datasource);
String wantToReloadServerGroup(String name);
String wantToRestartServerGroup(String name);
String wantToReloadHost(String name);
String wantToRestartHost(String name);
String wantToResumeServerGroup(String name);
String wantToStartServerGroup(String name);
String wantToStopServerGroup(String name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ verify_datasource_failed_message=Please verify the connection settings for datas
verify_datasource_successful_message=Successfully connected to database {0}.
wantToReloadServerGroup=Do you want to reload group {0}?
wantToRestartServerGroup=Do you want to restart group {0}?
wantToReloadHost=Do you want to reload host {0} ?
wantToRestartHost=Do you want to restart host {0} ?
wantToResumeServerGroup=Do you want to resume group {0}?
wantToStartServerGroup=Do you want to start group {0}?
wantToStopServerGroup=Do you want to stop group {0}?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public void execute() {
}
});


hosts.setMenuItems(
new MenuDelegate<String>( // TODO permissions
"JVM", new ContextualCommand<String>() {
Expand Down Expand Up @@ -336,6 +337,42 @@ public void executeOn(final String host) {
new PlaceRequest(NameTokens.HostInterfacesPresenter)
);
}
}),
new MenuDelegate<>(Console.CONSTANTS.common_label_reload(), new ContextualCommand<String>() {
@Override
public void executeOn(final String host) {
Feedback.confirm(
Console.CONSTANTS.reloadHost(),
Console.MESSAGES.wantToReloadHost(host),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed)
presenter.onHostControllerLifecycle(host, LifecycleOperation.RELOAD);
}
}
);

}
}),
// }, MenuDelegate.Role.Operation)
// .setOperationAddress("/{implicit.host}", "reload"),
new MenuDelegate<>(Console.CONSTANTS.common_label_restart(), new ContextualCommand<String>() {
@Override
public void executeOn(final String host) {
Feedback.confirm(
Console.CONSTANTS.restartHost(),
Console.MESSAGES.wantToRestartHost(host),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed)
presenter.onHostControllerLifecycle(host, LifecycleOperation.RESTART);
}
}
);

}
})


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@
import com.gwtplatform.mvp.client.annotations.ContentSlot;
import com.gwtplatform.mvp.client.annotations.NameToken;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.proxy.Place;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.Proxy;
import com.gwtplatform.mvp.client.proxy.RevealContentEvent;
import com.gwtplatform.mvp.client.proxy.RevealContentHandler;
import com.gwtplatform.mvp.client.proxy.*;
import com.gwtplatform.mvp.shared.proxy.PlaceRequest;

import org.jboss.as.console.client.Console;
import org.jboss.as.console.client.core.BootstrapContext;
import org.jboss.as.console.client.core.Header;
Expand All @@ -46,36 +41,21 @@
import org.jboss.as.console.client.domain.events.StaleModelEvent;
import org.jboss.as.console.client.domain.groups.CopyGroupWizard;
import org.jboss.as.console.client.domain.groups.NewServerGroupWizard;
import org.jboss.as.console.client.domain.model.ProfileRecord;
import org.jboss.as.console.client.domain.model.ServerGroupDAO;
import org.jboss.as.console.client.domain.model.ServerGroupRecord;
import org.jboss.as.console.client.domain.model.SimpleCallback;
import org.jboss.as.console.client.domain.model.*;
import org.jboss.as.console.client.domain.model.impl.LifecycleOperation;
import org.jboss.as.console.client.domain.topology.HostControllerOpV3;
import org.jboss.as.console.client.domain.topology.LifecycleCallback;
import org.jboss.as.console.client.domain.topology.ServerGroupOpV3;
import org.jboss.as.console.client.rbac.UnauthorisedPresenter;
import org.jboss.as.console.client.shared.BeanFactory;
import org.jboss.as.console.client.shared.properties.CreatePropertyCmd;
import org.jboss.as.console.client.shared.properties.DeletePropertyCmd;
import org.jboss.as.console.client.shared.properties.NewPropertyWizard;
import org.jboss.as.console.client.shared.properties.PropertyManagement;
import org.jboss.as.console.client.shared.properties.PropertyRecord;
import org.jboss.as.console.client.shared.properties.*;
import org.jboss.as.console.client.shared.state.PerspectivePresenter;
import org.jboss.as.console.client.shared.state.ReloadState;
import org.jboss.as.console.client.shared.util.DMRUtil;
import org.jboss.as.console.client.v3.dmr.AddressTemplate;
import org.jboss.as.console.client.v3.presenter.Finder;
import org.jboss.as.console.client.v3.stores.domain.HostStore;
import org.jboss.as.console.client.v3.stores.domain.ProfileStore;
import org.jboss.as.console.client.v3.stores.domain.ServerGroupStore;
import org.jboss.as.console.client.v3.stores.domain.ServerStore;
import org.jboss.as.console.client.v3.stores.domain.SocketBindingStore;
import org.jboss.as.console.client.v3.stores.domain.actions.CreateServerGroup;
import org.jboss.as.console.client.v3.stores.domain.actions.DeleteServerGroup;
import org.jboss.as.console.client.v3.stores.domain.actions.GroupSelection;
import org.jboss.as.console.client.v3.stores.domain.actions.RefreshHosts;
import org.jboss.as.console.client.v3.stores.domain.actions.RefreshServer;
import org.jboss.as.console.client.v3.stores.domain.actions.RefreshServerGroups;
import org.jboss.as.console.client.v3.stores.domain.*;
import org.jboss.as.console.client.v3.stores.domain.actions.*;
import org.jboss.as.console.client.widgets.nav.v3.FinderColumn;
import org.jboss.as.console.client.widgets.nav.v3.FinderScrollEvent;
import org.jboss.as.console.client.widgets.nav.v3.PreviewEvent;
Expand All @@ -90,11 +70,7 @@
import org.jboss.dmr.client.dispatch.impl.DMRResponse;
import org.jboss.gwt.circuit.Dispatcher;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;

import static org.jboss.dmr.client.ModelDescriptionConstants.*;

Expand Down Expand Up @@ -126,6 +102,7 @@ public PlaceManager getPlaceManager() {
"opt://server-group=*/system-property=*"},
recursive = false)
@SearchIndex(keywords = {"host", "jvm", "group", "server-group", "profile", "socket-binding"})
// @RequiredResources(resources = {"/{implicit.host}"})
public interface MyProxy extends Proxy<HostMgmtPresenter>, Place {
}

Expand Down Expand Up @@ -155,14 +132,15 @@ public interface MyView extends View {
private HandlerRegistration hostHandler;
private List<ProfileRecord> existingProfiles;
private final ReloadState reloadState;
private final HostInformationStore hostInformationStore;

@Inject
public HostMgmtPresenter(EventBus eventBus, MyView view, MyProxy proxy, PlaceManager placeManager,
BootstrapContext bootstrap, Header header, HostStore hostStore, Dispatcher circuit,
UnauthorisedPresenter unauthorisedPresenter, ServerStore serverStore,
ProfileStore profileStore, DispatchAsync dispatcher, BeanFactory factory,
ServerGroupDAO serverGroupDAO, ServerGroupStore serverGroupStore, SocketBindingStore socketBindingStore,
CoreGUIContext statementContext, ReloadState reloadState) {
CoreGUIContext statementContext, ReloadState reloadState, HostInformationStore hostInformationStore) {

super(eventBus, view, proxy, placeManager, header, NameTokens.HostMgmtPresenter,
TYPE_MainContent);
Expand All @@ -181,6 +159,7 @@ public HostMgmtPresenter(EventBus eventBus, MyView view, MyProxy proxy, PlaceMan
this.socketBindingStore = socketBindingStore;
this.statementContext = statementContext;
this.reloadState = reloadState;
this.hostInformationStore = hostInformationStore;
}

@Override
Expand Down Expand Up @@ -238,6 +217,7 @@ protected void onBind() {
@Override
public String resolve(AddressTemplate template) {
String resolved = template.resolveAsKey(statementContext, serverStore.getSelectedGroup());
LOG.info("resolved: " + resolved );
return resolved;
}
};
Expand Down Expand Up @@ -496,7 +476,7 @@ public void onError(Throwable caught) {
Console.error("Server " + op.name() + " failed", caught.getMessage());
circuit.dispatch(new RefreshServer());
}
}, dispatcher, serverGroupDAO, group, serverStore.getServerForGroup(group));
}, dispatcher, serverGroupDAO, group, serverStore.getServerForGroup(group));

serverGroupOp.run();

Expand All @@ -518,4 +498,41 @@ public void onLaunchSuspendDialogue(ServerGroupRecord group) {

}

public void onHostControllerLifecycle(final String host, final LifecycleOperation op) {

// parametrized lifecycle operations
if(window!=null) window.hide();

HostControllerOpV3 serverGroupOp = new HostControllerOpV3(op, new LifecycleCallback() {
@Override
public void onSuccess() {
Console.info("Host controller "+ op.name() + " succeeded");
circuit.dispatch(new RefreshServer());
Log.debug("HostMgmtPresenter reloadState null ? " + (reloadState == null ));
reloadState.reset();
}

@Override
public void onTimeout() {
Console.warning("Request timeout");
circuit.dispatch(new RefreshServer());
}

@Override
public void onAbort() {
Console.warning("Request aborted.");
circuit.dispatch(new RefreshServer());
}

@Override
public void onError(Throwable caught) {
Console.error("Server " + op.name() + " failed", caught.getMessage());
circuit.dispatch(new RefreshServer());
}
}, dispatcher, hostInformationStore, host, serverStore.getServerForHost(host));

serverGroupOp.run();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ public interface HostInformationStore {
void loadJVMConfiguration(String host, Server server, AsyncCallback<Jvm> callback);

void loadProperties(String host, Server server, AsyncCallback<List<PropertyRecord>> callback);

void reloadHost(String host, final AsyncCallback<Boolean> callback);
void restartHost(String host, final AsyncCallback<Boolean> callback);
}
Original file line number Diff line number Diff line change
Expand Up @@ -944,4 +944,52 @@ public void onSuccess(DMRResponse dmrResponse) {
}
});
}

public void reloadHost(String host, final AsyncCallback<Boolean> callback) {
final ModelNode operation = new ModelNode();
operation.get(OP).set("reload");
operation.get(ADDRESS).add("host", host);

dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();
if (response.isFailure()) {
callback.onSuccess(false);
} else {
callback.onSuccess(true);
}
}

@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
});

}
public void restartHost(String host, final AsyncCallback<Boolean> callback) {
final ModelNode operation = new ModelNode();
operation.get(OP).set("shutdown");
operation.get("restart").set(true);
operation.get(ADDRESS).add("host", host);


dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();
if (response.isFailure()) {
callback.onSuccess(false);
} else {
callback.onSuccess(true);
}
}

@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
});
}
}

0 comments on commit 2c4c5f3

Please sign in to comment.