Browse Source

Merge pull request #467 in DESIGN/design from ~JU/design:feature/10.0 to feature/10.0

* commit 'ef33237cae7086ad8214466854de4501d4ffc443':
  REPORT-11216 10.0远程设计问题解决 先传一波代码 1、拆分了rpc部分和channel部分 2、http channel写完好了 后续处理: 1、netty channel 2、gzip传输 3、图表地图资源太大导致图表卡的问题 4、其他性能优化 5、代码质量调整
research/10.0
ju 6 years ago
parent
commit
7021f24cad
  1. 15
      designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java
  2. 2
      designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java
  3. 5
      designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java
  4. 185
      designer-base/src/main/java/com/fr/env/RemoteEnvPane2.java
  5. 167
      designer-base/src/main/java/com/fr/env/RemoteEnvUtils.java
  6. 5
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

15
designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java vendored

@ -5,6 +5,7 @@ import com.fr.stable.AssistUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceClient;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.server.authority.decision.DecisionOperator;
@ -54,18 +55,30 @@ public class RemoteWorkspace implements Workspace {
@Override
public boolean isRoot() {
try {
return WorkContext.getCurrent().get(DecisionOperator.class).isRoot(WorkContext.getConnector().currentUser());
return WorkContext.getCurrent().get(DecisionOperator.class).isRoot(getConnection().getUserName());
} catch (Exception e) {
return false;
}
}
@Override
public WorkspaceConnection getConnection() {
return client.getConnection();
}
@Override
public <T> T get(Class<T> type) {
return client.getPool().get(type);
}
@Override
public void close() {
client.close();
}
@Override
public int hashCode() {

2
designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java

@ -39,7 +39,7 @@ public class NodeAuthProcessor {
authPaths.clear();
if (!WorkContext.getCurrent().isLocal()) {
try {
String username = WorkContext.getConnector().currentUser();
String username = WorkContext.getCurrent().getConnection().getUserName();
// 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities();
DesignAuthority authority = null;

5
designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java

@ -368,7 +368,7 @@ public class UserManagerPane extends BasicPane {
@Override
protected List<RemoteDesignMember> doInBackground() {
addingMembers.clear();
String username = WorkContext.getConnector().currentUser();
String username = WorkContext.getCurrent().getConnection().getUserName();
synchronized (addingMembers) {
Collection<RemoteDesignMember> more = WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword);
pageNum = 1;
@ -395,7 +395,8 @@ public class UserManagerPane extends BasicPane {
final SwingWorker loadMoreWorker = new SwingWorker<List<RemoteDesignMember>, Void>() {
@Override
protected List<RemoteDesignMember> doInBackground() {
String username = WorkContext.getConnector().currentUser();
String username = WorkContext.getCurrent().getConnection().getUserName();
synchronized (addingMembers) {
addingMembers.remove(RemoteDesignMember.DEFAULT_MEMBER);
Collection<RemoteDesignMember> more =

185
designer-base/src/main/java/com/fr/env/RemoteEnvPane2.java vendored

@ -1,185 +0,0 @@
//package com.fr.env;
//
//import com.fr.design.beans.BasicBeanPane;
//import com.fr.design.border.UITitledBorder;
//import com.fr.design.env.DesignerWorkspaceInfo;
//import com.fr.design.env.DesignerWorkspaceType;
//import com.fr.design.gui.ibutton.UIButton;
//import com.fr.design.gui.ilable.UILabel;
//import com.fr.design.gui.ipasswordfield.UIPassWordField;
//import com.fr.design.gui.itextfield.UIIntNumberField;
//import com.fr.design.gui.itextfield.UITextField;
//import com.fr.design.layout.TableLayout;
//import com.fr.design.layout.TableLayoutHelper;
//import com.fr.design.utils.gui.GUICoreUtils;
//
//import com.fr.workspace.WorkContext;
//import com.fr.workspace.connect.WorkspaceConnection;
//
//import javax.swing.*;
//import javax.swing.border.EmptyBorder;
//import java.awt.*;
//import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;
//import java.awt.event.WindowAdapter;
//import java.awt.event.WindowEvent;
//
///**
// * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane
// */
//public class RemoteEnvPane2 extends BasicBeanPane<DesignerWorkspaceInfo> {
//
// private UITextField urlTextField;
// private UITextField usernameTextField;
// private UIPassWordField passwordTextField;
// private JDialog dialog;
// private UILabel message;
// private UIButton okButton;
// private UIButton cancelButton;
//
// public RemoteEnvPane2() {
// initComponents();
// }
//
// private void initComponents() {
// setLayout(new BorderLayout());
//
// JPanel contentPanel = new JPanel(new BorderLayout());
// add(contentPanel, BorderLayout.CENTER);
//
// contentPanel.setBorder(
// BorderFactory.createCompoundBorder(
// new EmptyBorder(6, 0, 0, 0),
// UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Config")))
// );
//
// double p = TableLayout.PREFERRED;
// double f = TableLayout.FILL;
// double[] rowSize = new double[]{p, p, p, p};
// double[] columnSize = new double[]{p, f};
// UIButton testConnectionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Try"));
// urlTextField = new UITextField();
// urlTextField.setPlaceholder("http://192.168.100.200/webroot/decision");
// JPanel valuePane = TableLayoutHelper.createTableLayoutPane(
// new Component[][]{
// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), urlTextField},
// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()},
// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()},
// {null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)}
// },
// rowSize, columnSize
// );
// testConnectionButton.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// tryConnectRemoteEnv();
// }
// });
// contentPanel.add(valuePane, BorderLayout.CENTER);
//
// message = new UILabel();
// okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("OK"));
// cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Cancel"));
// }
//
// private void tryConnectRemoteEnv() {
// final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
//
// @Override
// protected Void doInBackground() throws Exception {
//
// final DesignerWorkspaceInfo remoteEnv = updateBean();
// WorkContext.getConnector().testConnection(remoteEnv.getConnection());
// return null;
// }
//
// @Override
// protected void done() {
// okButton.setEnabled(true);
// try {
// get();
// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Connect_Successful"));
// } catch (Exception e) {
// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Connect_Failed"));
// }
// }
// };
// worker.execute();
// initMessageDialog();
// okButton.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// dialog.dispose();
// }
// });
// cancelButton.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// dialog.dispose();
// worker.cancel(true);
// }
// });
//
// dialog.addWindowListener(new WindowAdapter() {
// public void windowClosed(WindowEvent e) {
// worker.cancel(true);
// }
// });
//
// dialog.setVisible(true);
// dialog.dispose();
// }
//
// private void initMessageDialog() {
// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Try") + "...");
// message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
// okButton.setEnabled(false);
//
// dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), com.fr.design.i18n.Toolkit.i18nText("Datasource-Test_Connection"), true);
//
// dialog.setSize(new Dimension(268, 118));
// okButton.setEnabled(false);
// JPanel jp = new JPanel();
// JPanel upPane = new JPanel();
// JPanel downPane = new JPanel();
// UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
// upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
// upPane.add(uiLabel);
// upPane.add(message);
// downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
// downPane.add(okButton);
// downPane.add(cancelButton);
// jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
// jp.add(upPane);
// jp.add(downPane);
// dialog.add(jp);
// dialog.setResizable(false);
// dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this));
// }
//
// @Override
// protected String title4PopupWindow() {
// return "RemoteEnv";
// }
//
// @Override
// public void populateBean(DesignerWorkspaceInfo config) {
// if (config == null) {
// return;
// }
// WorkspaceConnection connection = config.getConnection();
// if (connection != null) {
// urlTextField.setText(connection.getUrl());
// usernameTextField.setText(connection.getUserName());
// passwordTextField.setText(connection.getPassword());
// }
// }
//
// @Override
// public DesignerWorkspaceInfo updateBean() {
//
// DesignerWorkspaceInfo config = new DesignerWorkspaceInfo();
// WorkspaceConnection connection = new WorkspaceConnection(urlTextField.getText(), usernameTextField.getText(), passwordTextField.getText());
// config.setConnection(connection);
// config.setType(DesignerWorkspaceType.Remote);
// return config;
// }
//}

167
designer-base/src/main/java/com/fr/env/RemoteEnvUtils.java vendored

@ -1,167 +0,0 @@
//package com.fr.env;
//
//import com.fr.base.EnvException;
//import com.fr.base.FRContext;
//import com.fr.report.DesignAuthority;
//import com.fr.report.util.AuthorityXMLUtils;
//import com.fr.stable.EncodeConstants;
//import com.fr.third.org.apache.commons.io.IOUtils;
//import com.fr.third.org.apache.http.HttpResponse;
//import com.fr.third.org.apache.http.HttpStatus;
//import com.fr.third.org.apache.http.client.ClientProtocolException;
//import com.fr.third.org.apache.http.client.ResponseHandler;
//import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
//import com.fr.third.org.apache.http.client.methods.RequestBuilder;
//import com.fr.third.org.apache.http.entity.ContentType;
//import com.fr.third.org.apache.http.entity.InputStreamEntity;
//import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
//import com.fr.third.org.apache.http.impl.client.HttpClients;
//
//import java.io.ByteArrayInputStream;
//import java.io.ByteArrayOutputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.net.URLEncoder;
//import java.util.Map;
//
//public class RemoteEnvUtils {
//
// private RemoteEnvUtils() {
// }
//
// private static ResponseHandler<InputStream> responseHandler = new ResponseHandler<InputStream>() {
// @Override
// public InputStream handleResponse(HttpResponse response) throws IOException {
// int statusCode = response.getStatusLine().getStatusCode();
// if (statusCode != HttpStatus.SC_OK) {
// throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString());
// }
// InputStream in = response.getEntity().getContent();
// if (in == null) {
// return null;
// }
// // 读取并返回
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// IOUtils.copy(in, out);
// return new ByteArrayInputStream(out.toByteArray());
// }
// };
//
// public static InputStream simulateRPCByHttpPost(byte[] bytes, Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
// String path = env.getPath();
// RequestBuilder builder = RequestBuilder.post(path);
//
// InputStream inputStream = null;
//
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
// builder.addParameter(entry.getKey(), entry.getValue());
// }
// if (!isSignIn) {
// builder.addParameter("id", env.getUserID());
// }
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes));
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = builder
// .setEntity(reqEntity)
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage(), e);
// }
// return inputStream;
// }
//
// public static InputStream simulateRPCByHttpPost(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
// String path = env.getPath();
// RequestBuilder builder = RequestBuilder.post(path);
//
// InputStream inputStream = null;
//
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
// builder.addParameter(entry.getKey(), entry.getValue());
// }
// if (!isSignIn) {
// builder.addParameter("id", env.getUserID());
// }
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = builder
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage(), e);
// }
// return inputStream;
// }
//
// public static InputStream simulateRPCByHttpGet(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
// String path = env.getPath();
// RequestBuilder builder = RequestBuilder.get(path);
//
// InputStream inputStream = null;
//
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
// builder.addParameter(entry.getKey(), entry.getValue());
// }
// if (!isSignIn) {
// builder.addParameter("id", env.getUserID());
// }
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = builder.build();
// inputStream = httpClient.execute(request, responseHandler);
//
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage(), e);
// }
// return inputStream;
// }
//
//
// public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) {
// String path = env.getPath();
// // 远程设计临时用户id
// String userID = env.getUserID();
// InputStream inputStream = null;
//
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream);
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML);
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = RequestBuilder.post(path)
// .addParameter("id", userID)
// .addParameter("op", "remote_design_authority")
// .addParameter("cmd", "update_authorities")
// .setEntity(reqEntity)
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage(), e);
// }
//
// return inputStream;
//
// }
//
// public static InputStream getAuthorities(RemoteEnv env) throws EnvException {
// String path = env.getPath();
// // 远程设计临时用户id
// String userID = env.getUserID();
// InputStream inputStream = null;
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem();) {
// HttpUriRequest request = RequestBuilder.get(path)
// .addParameter("id", userID)
// .addParameter("op", "remote_design_authority")
// .addParameter("cmd", "get_authorities")
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage(), e);
// }
// return inputStream;
// }
//
//
//}

5
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -16,8 +16,7 @@ import com.fr.third.guava.base.Optional;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.base.WorkspaceConstants;
import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient;
import com.fr.workspace.server.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.server.socket.SocketInfoOperator;
import io.socket.client.IO;
import io.socket.client.Socket;
@ -113,7 +112,7 @@ public class DesignerSocketIO {
private static String getSocketUri(Workspace current) throws IOException {
URL url = new URL(current.getPath());
int port = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort();
WorkspaceConnection connection = RemoteCallClient.getInstance().getConnection();
WorkspaceConnection connection = WorkContext.getCurrent().getConnection();
return String.format("%s://%s:%s%s?%s=%s&%s=%s",
url.getProtocol(),
url.getHost(),

Loading…
Cancel
Save