Skip to content

Commit 79a92e3

Browse files
author
zhangjunfeng
committed
ui
1 parent bdb43eb commit 79a92e3

14 files changed

Lines changed: 181 additions & 165 deletions

File tree

modules/vertx-rest/src/main/java/org/apache/ignite/internal/processors/rest/igfs/controller/S3VertxRestController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ private S3Service s3Service() {
9292
if(s3==null) {
9393
try {
9494
Ignite ignite = Ignition.ignite(region);
95-
s3 = new S3IgfsServiceImpl(region,systemConfig);
95+
if(!ignite.fileSystems().isEmpty())
96+
s3 = new S3IgfsServiceImpl(region,systemConfig);
97+
else
98+
s3 = new S3LocalFileServiceImpl(region,systemConfig);
9699
}
97100
catch(Exception e) {
98101
s3 = new S3LocalFileServiceImpl(region,systemConfig);

modules/vertx-rest/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,9 @@ private void override(HttpServerOptions con) {
232232
* @return {@code True} if Vertx started.
233233
*/
234234
private boolean configSingletonJetty() throws IgniteCheckedException {
235-
236-
String jettyHost = System.getProperty(IGNITE_JETTY_HOST, ctx.config().getLocalHost());
237235

238236
try {
239-
System.setProperty(IGNITE_JETTY_HOST, U.resolveLocalHost(jettyHost).getHostAddress());
237+
240238
String jettyPath = config().getJettyPath();
241239
final URL cfgUrl;
242240

@@ -259,7 +257,7 @@ else if (log.isDebugEnabled())
259257

260258
}
261259
catch (IOException e) {
262-
throw new IgniteCheckedException("Failed to resolve host to bind address: " + jettyHost, e);
260+
throw new IgniteCheckedException("Failed to loadJettyConfiguration: ", e);
263261
}
264262

265263
return true;
@@ -304,22 +302,29 @@ private void loadJettyConfiguration(@Nullable URL cfgUrl) throws IgniteCheckedEx
304302

305303
context.start();
306304

307-
if (cfgUrl == null) {
305+
if (cfgUrl == null || cfgUrl.getPort()>0) {
308306
HttpServerOptions srvConn = new HttpServerOptions();
309307

310-
String srvPortStr = System.getProperty(IGNITE_JETTY_PORT, ""+8080);
308+
String jettyHost = System.getProperty(IGNITE_JETTY_HOST, ctx.config().getLocalHost());
311309

312310
int srvPort;
313311

314-
try {
315-
srvPort = Integer.parseInt(srvPortStr);
312+
if(cfgUrl == null) {
313+
jettyHost = U.resolveLocalHost(jettyHost).getHostAddress();
314+
String srvPortStr = System.getProperty(IGNITE_JETTY_PORT, "" + 8080);
315+
try {
316+
srvPort = Integer.parseInt(srvPortStr);
317+
} catch (NumberFormatException ignore) {
318+
context.close();
319+
throw new IgniteCheckedException("Failed to start Vertx server because IGNITE_JETTY_PORT system property cannot be cast to integer: " + srvPortStr);
320+
}
321+
}
322+
else{
323+
srvPort = cfgUrl.getPort();
324+
jettyHost = cfgUrl.getHost();
316325
}
317-
catch (NumberFormatException ignore) {
318-
context.close();
319-
throw new IgniteCheckedException("Failed to start Vertx server because IGNITE_JETTY_PORT system property cannot be cast to integer: " + srvPortStr);
320-
}
321326

322-
srvConn.setHost(System.getProperty(IGNITE_JETTY_HOST, "localhost"));
327+
srvConn.setHost(jettyHost);
323328
srvConn.setPort(srvPort);
324329
srvConn.setIdleTimeout(60000);
325330
srvConn.setReuseAddress(true);

web-console/frontend/app/components/web-console-header/components/demo-mode-button/controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

2-
2+
import _ from 'lodash';
33
import {StateService} from '@uirouter/angularjs';
44
import {default as LegacyConfirmFactory} from 'app/services/Confirm.service';
5+
import AgentManager from 'app/modules/agent/AgentManager.service';
56
import {UserService} from '../../../../modules/user/User.service';
67
import {take} from 'rxjs/operators';
78

web-console/web-agent/src/main/java/org/apache/ignite/console/agent/IgniteClusterLauncher.java

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -206,37 +206,32 @@ public static void deployServices(IgniteServices services) {
206206
//services.deployKeyAffinitySingleton("loadDataKeyAffinityService",new ClusterLoadDataService(), cacheName, "id");
207207
}
208208

209-
/** */
210-
public static String registerNodeUrl(Ignite ignite,String clusterId) {
211-
ClusterNode node = ignite.cluster().localNode();
212-
213-
Collection<String> jettyAddrs = node.attribute(ATTR_REST_JETTY_ADDRS);
209+
public static String getNodeRestUrl(Ignite ignite) {
210+
ClusterNode node = ignite.cluster().localNode();
214211

215-
if (jettyAddrs == null) {
216-
throw new IgniteException("Cluster: Failed to start Jetty REST server on embedded node");
217-
}
212+
Collection<String> jettyAddrs = node.attribute(ATTR_REST_JETTY_ADDRS);
218213

219-
String jettyHost = "127.0.0.1";
220-
for(String host: jettyAddrs) {
221-
if(!host.startsWith("0")) {
222-
jettyHost = host;
223-
}
224-
}
225-
226-
Integer jettyPort = node.attribute(ATTR_REST_JETTY_PORT);
214+
if (jettyAddrs == null) {
215+
throw new IgniteException("Cluster: Failed to start Jetty REST server on embedded node");
216+
}
227217

228-
if (F.isEmpty(jettyHost) || jettyPort == null)
229-
throw new IgniteException("Cluster: Failed to start Jetty REST handler on embedded node");
218+
String jettyHost = "127.0.0.1";
219+
for(String host: jettyAddrs) {
220+
if(!host.startsWith("0")) {
221+
jettyHost = host;
222+
}
223+
}
230224

231-
log.info("Cluster: Started embedded node for data analysis purpose [TCP binary port={}, Jetty REST port={}]", ignite.configuration().getConnectorConfiguration().getPort(), jettyPort);
225+
Integer jettyPort = node.attribute(ATTR_REST_JETTY_PORT);
232226

233-
String nodeUrl = String.format("http://%s:%d", jettyHost, jettyPort);
227+
if (F.isEmpty(jettyHost) || jettyPort == null)
228+
throw new IgniteException("Cluster: Failed to start Jetty REST handler on embedded node");
234229

235-
RestClusterHandler.registerNodeUrl(clusterId,nodeUrl,ignite.name());
236-
237-
return nodeUrl;
238-
}
230+
log.info("Cluster: Started embedded node for data analysis purpose [TCP binary port={}, Jetty REST port={}]", ignite.configuration().getConnectorConfiguration().getPort(), jettyPort);
239231

232+
String nodeUrl = String.format("http://%s:%d", jettyHost, jettyPort);
233+
return nodeUrl;
234+
}
240235

241236
/** */
242237
public static void stopIgnite(String clusterName,String clusterId) {
@@ -370,20 +365,18 @@ public static Ignite trySingleStart(String clusterId,String clusterName,int node
370365
* Start ignite node with cacheEmployee and populate it with data.
371366
* @throws IgniteCheckedException
372367
*/
373-
public static String saveBlobToFile(JsonObject json,Collection<String> validTokens,List<String> messages) throws IgniteCheckedException {
374-
String clusterName = json.getString("name");
368+
public static boolean saveBlobToFile(JsonObject json,String destPath,List<String> messages) throws IgniteCheckedException {
369+
370+
String clusterName = json.getString("name");
375371
String base64 = json.getString("blob");
376372
String prefix = "data:application/octet-stream;base64,";
377-
if (base64!=null && base64.startsWith(prefix)) {
378-
373+
if (base64!=null && base64.startsWith(prefix)) {
379374
String fileName = Utils.escapeFileName(clusterName);
380-
381-
String work = U.workDirectory(null, null)+ "/config/";
382-
U.mkdirs(new File(work));
375+
U.mkdirs(new File(destPath));
383376

384377
byte[] zip = Base64.decodeBase64(base64.substring(prefix.length()));
385-
File zipFile = new File(work, fileName+".zip");
386-
String descDir = work + fileName+"/";
378+
File zipFile = new File(destPath, fileName+".zip");
379+
String descDir = destPath + fileName+"/";
387380

388381
try {
389382
FileOutputStream writer = new FileOutputStream(zipFile);
@@ -392,20 +385,14 @@ public static String saveBlobToFile(JsonObject json,Collection<String> validToke
392385

393386
AgentUtils.unZip(zipFile, descDir);
394387

395-
if(json.containsKey("crudui")) {
396-
CrudUICodeGenerator codeGen = new CrudUICodeGenerator();
397-
List<String> codeMessages = codeGen.generator(descDir,json.getMap(),validTokens);
398-
messages.addAll(codeMessages);
399-
}
400-
401-
return descDir;
388+
return true;
402389

403390
} catch (IOException e) {
404391
log.error("Failed to save zip blob data!",e);
405392
messages.add(e.getMessage());
406393
}
407394
}
408-
return null;
395+
return false;
409396

410397
}
411398

@@ -488,7 +475,6 @@ public static JsonObject callClusterCommand(Ignite ignite,String cmdName,JsonObj
488475
cmdReg = ((IgniteEx)ignite).commandsRegistry();
489476
}
490477

491-
492478
List<JsonObject> results = new ArrayList<>(10);
493479
Iterator<Entry<String, Command<?, ?>>> it = cmdReg.commands();
494480
while (it.hasNext()) {

web-console/web-agent/src/main/java/org/apache/ignite/console/agent/commandline/CommandsProviderExtImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.ignite.IgniteCheckedException;
2929
import org.apache.ignite.client.IgniteClient;
3030
import org.apache.ignite.console.agent.IgniteClusterLauncher;
31+
import org.apache.ignite.console.agent.handlers.RestClusterHandler;
3132
import org.apache.ignite.internal.client.GridClient;
3233

3334
import org.apache.ignite.internal.dto.IgniteDataTransferObject;
@@ -74,8 +75,8 @@ public static class NodeStartCommand implements LocalCommand<NodeStartCommandArg
7475
try {
7576
ignite = IgniteClusterLauncher.trySingleStart(arg.clusterId(), arg.instanceName(), 0, isLastNode, arg.cfgPath());
7677
if(ignite!=null && isLastNode) {
77-
IgniteClusterLauncher.registerNodeUrl(ignite,arg.clusterId());
78-
78+
String nodeRestUrl = IgniteClusterLauncher.getNodeRestUrl(ignite);
79+
RestClusterHandler.registerNodeUrl(arg.clusterId(),arg.instanceName(),nodeRestUrl);
7980
IgniteClusterLauncher.deployServices(ignite.services(ignite.cluster().forServers()));
8081
return true;
8182
}

web-console/web-agent/src/main/java/org/apache/ignite/console/agent/db/DataSourceManager.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ public static void init(HttpClient client,String serverUri,Collection<String> to
114114
// Activate the initial context
115115
NamingManager.setInitialContextFactoryBuilder(environment -> environment1 -> new DBinitialContext());
116116

117-
DBInfo demoDB = new DBInfo();
118-
demoDB.setDb("demodb");
119-
demoDB.setJdbcUrl("jdbc:h2:mem:demodb");
120-
demoDB.setUserName("sa");
121-
122-
bindDataSource("dsH2",demoDB);
123117
} catch (NamingException e) {
124118
// TODO Auto-generated catch block
125119
e.printStackTrace();

web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/DemoClusterHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public List<TopologySnapshot> topologySnapshot() {
6969

7070
if (AgentClusterDemo.getDemoUrl() != null) {
7171
try {
72-
IgniteEx ignite = (IgniteEx)Ignition.ignite(AgentClusterDemo.SRV_NODE_NAME);
72+
IgniteEx ignite = (IgniteEx)Ignition.ignite(DEMO_CLUSTER_NAME);
7373
if(DEMO_CLUSTER_ID == null) {
7474
DEMO_CLUSTER_ID = ignite.cluster().id().toString();
7575
}

web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestClusterHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
*/
4545
public class RestClusterHandler extends AbstractClusterHandler {
4646

47-
4847
/** Index of alive node URI. */
4948
private final Map<List<String>, Integer> startIdxs = U.newHashMap(2);
5049

@@ -75,7 +74,7 @@ public RestClusterHandler(AgentConfiguration cfg) {
7574
serverUri = cfg.serverUri();
7675
}
7776

78-
public static void registerNodeUrl(String clusterId,String url,String clusterName) {
77+
public static void registerNodeUrl(String clusterId,String clusterName,String url) {
7978
List<String> urls = clusterUrlMap.get(clusterId);
8079
if(urls==null) {
8180
urls = new ArrayList<>(1);

0 commit comments

Comments
 (0)