You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2016/09/12 11:30:33 UTC
[1/6] ambari git commit: AMBARI-18310. Refactor logsearch portal code
- part 3 (oleewere)
Repository: ambari
Updated Branches:
refs/heads/branch-dev-logsearch 4c19f4a26 -> 3013589a1
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/dashboard/MainLayoutView_tmpl.html
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/dashboard/MainLayoutView_tmpl.html b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/dashboard/MainLayoutView_tmpl.html
index c79ed1d..bc59f76 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/dashboard/MainLayoutView_tmpl.html
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/dashboard/MainLayoutView_tmpl.html
@@ -43,12 +43,6 @@
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
- <!-- <a class="">
- <i class="fa fa-gear"></i>
- </a>
- <a class="close-link">
- <i class="fa fa-close"></i>
- </a> -->
</div>
<div class="no-move"></div>
</div>
@@ -62,71 +56,6 @@
</div>
</div>
</div>
- <!-- div class="col-md-3">
- <div class="box">
- <div class="box-header">
- <div class="box-name">
- <span>Time Range</span>
- </div>
- <div class="box-icons">
- <a class="collapse-link">
- <i class="fa fa-chevron-up"></i>
- </a>
- <a class="">
- <i class="fa fa-gear"></i>
- </a>
- <a class="close-link">
- <i class="fa fa-close"></i>
- </a>
- </div>
- <div class="no-move"></div>
- </div>
- <div class="box-content">
- <div class="btn-group btn-group-sm">
- <button class="btn btn-primary">15m</button>
- <button class="btn btn-primary">1h</button>
- <button class="btn btn-primary">24h</button>
- </div>
- </div>
- </div>
- </div>
- <div class="col-md-6">
- <div class="box">
- <div class="box-header">
- <div class="box-name">
- <span>Filtering</span>
- </div>
- <div class="box-icons">
- <a class="collapse-link">
- <i class="fa fa-chevron-up"></i>
- </a>
- <a class="">
- <i class="fa fa-gear"></i>
- </a>
- <a class="close-link">
- <i class="fa fa-close"></i>
- </a>
- </div>
- <div class="no-move"></div>
- </div>
- <div class="box-content">
- <table class="table-bordered table-condensed">
- <tr>
- <th>Time</th>
- <td colspan="5">must</td>
- </tr>
- <tr>
- <th>field</th>
- <td>logtime</td>
- <th>from</th>
- <td>2014-12-17T04:59:00.362Z</td>
- <th>to</th>
- <td>2015-06-15T04:59:00.363Z</td>
- </tr>
- </table>
- </div>
- </div>
- </div-->
</div>
<div class="row">
<div class="col-md-3">
@@ -143,56 +72,6 @@
</div>
<div class="col-md-9">
<div id="r_BubbleTable"></div>
- <!-- <div class="box no-drop">
- <div class="box-header">
- <div class="box-name">
- <span>Log Data</span>
- </div>
- <div class="box-icons">
- <span id="loaderGraph">
- <i class="fa fa-spinner fa-spin"></i>
- </span>
- <a class="">
- <i class="fa fa-save"></i>
- </a>
- <a class="">
- <i class="fa fa-info"></i>
- </a>
- <a class="">
- <i class="fa fa-gear"></i>
- </a>
- <a class="collapse-link">
- <i class="fa fa-chevron-up"></i>
- </a>
- <a class="close-link">
- <i class="fa fa-close"></i>
- </a>
- </div>
- <div class="no-move"></div>
- </div>
- <div class="box-content">
- <div class="">
- <div class="radio-inline">
- <label>
- <input type="radio" name="viewType" value="G" checked=""> Graph
- <i class="fa fa-circle-o small"></i>
- </label>
- </div>
- <div class="radio-inline">
- <label>
- <input type="radio" name="viewType" value="T"> Table
- <i class="fa fa-circle-o small"></i>
- </label>
- </div>
- </div>
- <div data-id="table" style="display:none;">
- <div id=control></div>
- <div id="rLogTable" ></div>
- </div>
-
- <div id="graphAgg"></div>
- </div>
- </div> -->
</div>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js
index f4f1d32..151335d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js
@@ -22,7 +22,6 @@
var Handlebars = require('handlebars');
var Util = require('utils/Utils');
var localization = require('utils/LangSupport');
- var SessionMgr = require('mgrs/SessionMgr');
require('moment');
/*
* General guidelines while writing helpers:
@@ -274,18 +273,12 @@
return 'styles/images/avatar' + parseInt(((Math.random()*10)%4) + 1,10) + '.png';
});
Handlebars.registerHelper('isSystemAdmin', function(context, options) {
- if(SessionMgr.isSystemAdmin())
- return options.fn(this);
return options.inverse(this);
});
Handlebars.registerHelper('isSchoolAdmin', function(context, options) {
- if(SessionMgr.isSchoolAdmin() || SessionMgr.isSystemAdmin())
- return options.fn(this);
return options.inverse(this);
});
Handlebars.registerHelper('isTeacher', function(context, options) {
- if(SessionMgr.isTeacher())
- return options.fn(this);
return options.inverse(this);
});
Handlebars.registerHelper('getAvatar', function(options,size) {
@@ -510,41 +503,9 @@
}
return new Handlebars.SafeString(html);
});
- // Handlebars.registerHelper('getServices', function(services, serviceDef) {
- // var XAEnums = require('utils/XAEnums');
- // var tr = '', serviceOperationDiv = '';
- // var serviceType = serviceDef.get('name');
- // if(!_.isUndefined(services[serviceType])){
- // _.each(services[serviceType],function(serv){
- // serviceName = serv.get('name');
- // if(SessionMgr.isSystemAdmin()){
- // serviceOperationDiv = '<div class="pull-right">\
- // <a data-id="'+serv.id+'" class="btn btn-mini" href="#!/service/'+serviceDef.id+'/edit/'+serv.id+'" title="Edit"><i class="icon-edit"></i></a>\
- // <a data-id="'+serv.id+'" class="deleteRepo btn btn-mini btn-danger" href="javascript:void(0);" title="Delete">\
- // <i class="icon-trash"></i></a>\
- // </div>'
- // }
- // tr += '<tr><td><div>\
- // <a data-id="'+serv.id+'" href="#!/service/'+serv.id+'/policies">'+_.escape(serv.attributes.name)+'</a>'+serviceOperationDiv+'\
- // </div></td></tr>';
- // });
- // }
- // return tr;
- // });
Handlebars.registerHelper('capitaliseLetter', function(str) {
return str.toUpperCase();
});
- // Handlebars.registerHelper('hasAccessToTab', function(tabName,options) {
- // var vxPortalUser = SessionMgr.getUserProfile();
- // var userModules = _.pluck(vxPortalUser.get('userPermList'), 'moduleName');
- // var groupModules = _.pluck(vxPortalUser.get('groupPermissions'), 'moduleName');
- // var moduleNames = _.union(userModules,groupModules);
- // var returnFlag = _.contains(moduleNames, tabName);
- // if (returnFlag)
- // return options.fn(this);
- // else
- // return options.inverse(this);
- // });
/*logserach*/
Handlebars.registerHelper ("setChecked", function (value, currentValue) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
deleted file mode 100644
index 017d7a8..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.dao;
-
-import java.util.ArrayList;
-
-import org.apache.ambari.logsearch.conf.SolrAuditLogConfig;
-import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.request.CollectionAdminRequest;
-import org.apache.solr.common.util.NamedList;
-import org.easymock.Capture;
-import org.easymock.CaptureType;
-import org.easymock.EasyMock;
-import org.easymock.EasyMockSupport;
-import org.easymock.Mock;
-import org.easymock.TestSubject;
-import org.junit.Before;
-import org.junit.Test;
-
-import junit.framework.Assert;
-
-public class AuditSolrDaoTest {
-
- @TestSubject
- private AuditSolrDao dao = new AuditSolrDao();
-
- @Mock
- private SolrAuditLogConfig configMock;
-
- @Mock
- private SolrKerberosConfig kerbConfigMock;
-
- @Before
- public void setUp() {
- EasyMockSupport.injectMocks(this);
- }
-
- @Test
- public void testAuditSolrDaoPostConstructor() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
-
- NamedList<Object> response = new NamedList<Object>();
- NamedList<Object> header = new NamedList<Object>();
- header.add("status", 0);
- response.add("responseHeader", header);
- response.add("collections", new ArrayList<String>());
-
- EasyMock.expect(configMock.getSolrUrl()).andReturn(null);
- EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181");
- EasyMock.expect(configMock.getConfigName()).andReturn("test_audit_logs_config_name");
- EasyMock.expect(configMock.getCollection()).andReturn("test_audit_logs_collection");
- EasyMock.expect(configMock.getSplitInterval()).andReturn("none");
- EasyMock.expect(configMock.getNumberOfShards()).andReturn(123);
- EasyMock.expect(configMock.getReplicationFactor()).andReturn(456);
- EasyMock.expect(configMock.getAliasNameIn()).andReturn("alias");
- EasyMock.expect(configMock.getRangerCollection()).andReturn("ranger_audit");
- EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
- EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
-
- Capture<CollectionAdminRequest.Create> captureCreateRequest = EasyMock.newCapture(CaptureType.LAST);
-
- EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
-
- mockSolrClient.request(EasyMock.capture(captureCreateRequest), EasyMock.anyString());
- EasyMock.expectLastCall().andReturn(response);
-
- EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
-
- dao.solrClient = mockSolrClient;
- dao.isZkConnectString = true;
-
- dao.postConstructor();
- EasyMock.verify(mockSolrClient);
-
- CollectionAdminRequest.Create createRequest = captureCreateRequest.getValue();
- Assert.assertEquals(createRequest.getConfigName(), "test_audit_logs_config_name");
- Assert.assertEquals(createRequest.getNumShards().intValue(), 123);
- Assert.assertEquals(createRequest.getReplicationFactor().intValue(), 456);
- Assert.assertEquals(createRequest.getCollectionName(), "test_audit_logs_collection");
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
deleted file mode 100644
index bdee8a8..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.dao;
-
-import java.util.ArrayList;
-
-import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
-import org.apache.ambari.logsearch.conf.SolrServiceLogConfig;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.request.CollectionAdminRequest;
-import org.apache.solr.common.util.NamedList;
-import org.easymock.Capture;
-import org.easymock.CaptureType;
-import org.easymock.EasyMock;
-import org.easymock.EasyMockSupport;
-import org.easymock.Mock;
-import org.easymock.TestSubject;
-import org.junit.Before;
-import org.junit.Test;
-
-import junit.framework.Assert;
-
-public class ServiceLogsSolrDaoTest {
-
- @TestSubject
- private ServiceLogsSolrDao dao = new ServiceLogsSolrDao();
-
- @Mock
- private SolrKerberosConfig kerbConfigMock;
-
- @Mock
- private SolrServiceLogConfig configMock;
-
- @Before
- public void setUp() {
- EasyMockSupport.injectMocks(this);
- }
-
- @Test
- public void testServiceLogsSolrDaoPostConstructor() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
-
- NamedList<Object> response = new NamedList<Object>();
- NamedList<Object> header = new NamedList<Object>();
- header.add("status", 0);
- response.add("responseHeader", header);
- response.add("collections", new ArrayList<String>());
-
- EasyMock.expect(configMock.getSolrUrl()).andReturn(null);
- EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181");
- EasyMock.expect(configMock.getConfigName()).andReturn("test_service_logs_config_name");
- EasyMock.expect(configMock.getCollection()).andReturn("test_service_logs_collection");
- EasyMock.expect(configMock.getSplitInterval()).andReturn("none");
- EasyMock.expect(configMock.getNumberOfShards()).andReturn(789);
- EasyMock.expect(configMock.getReplicationFactor()).andReturn(987);
- EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
- EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
-
- Capture<CollectionAdminRequest.Create> captureCreateRequest = EasyMock.newCapture(CaptureType.LAST);
-
- EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
- mockSolrClient.request(EasyMock.capture(captureCreateRequest), EasyMock.anyString()); EasyMock.expectLastCall().andReturn(response);
-
- EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
-
- dao.solrClient = mockSolrClient;
- dao.isZkConnectString = true;
-
- dao.postConstructor();
- EasyMock.verify(mockSolrClient, configMock, kerbConfigMock);
-
- CollectionAdminRequest.Create createRequest = captureCreateRequest.getValue();
- Assert.assertEquals(createRequest.getConfigName(), "test_service_logs_config_name");
- Assert.assertEquals(createRequest.getNumShards().intValue(), 789);
- Assert.assertEquals(createRequest.getReplicationFactor().intValue(), 987);
- Assert.assertEquals(createRequest.getCollectionName(), "test_service_logs_collection");
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
deleted file mode 100644
index 22b10c3..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.dao;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import javax.ws.rs.WebApplicationException;
-
-import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrRequest.METHOD;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.client.solrj.impl.HttpSolrClient;
-import org.apache.solr.client.solrj.request.CollectionAdminRequest;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.util.NamedList;
-import org.easymock.EasyMock;
-import org.easymock.EasyMockSupport;
-import org.easymock.Mock;
-import org.easymock.TestSubject;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import junit.framework.Assert;
-
-public class SolrDaoBaseTest {
-
- @TestSubject
- private SolrDaoBase dao = new SolrDaoBase(LogType.SERVICE) {};
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Mock
- private SolrKerberosConfig kerbConfigMock;
-
- @Before
- public void setUp() {
- EasyMockSupport.injectMocks(this);
- }
-
- // ----------------------------------------------------------- connectToSolr -----------------------------------------------------------
-
- @Test
- public void testConnectToSolrWithConnectString() throws Exception {
- EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
- EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
-
- EasyMock.replay(kerbConfigMock);
-
- SolrClient solrClient = dao.connectToSolr(null, "zk_connect_string", "collection");
-
- Assert.assertEquals(solrClient.getClass(), CloudSolrClient.class);
- }
-
- @Test
- public void testConnectToSolrWithUrl() throws Exception {
- EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
- EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
-
- EasyMock.replay(kerbConfigMock);
-
- SolrClient solrClient = dao.connectToSolr("url", null, "collection");
-
- Assert.assertEquals(solrClient.getClass(), HttpSolrClient.class);
- }
-
- @Test
- public void testConnectToSolrWithBoth() throws Exception {
- EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
- EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
-
- EasyMock.replay(kerbConfigMock);
-
- SolrClient solrClient = dao.connectToSolr("url", "zk_connect_string", "collection");
-
- Assert.assertEquals(solrClient.getClass(), CloudSolrClient.class);
- }
-
- @Test
- public void testConnectToSolrWithNeither() throws Exception {
- EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
- EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
-
- EasyMock.replay(kerbConfigMock);
-
- expectedException.expect(Exception.class);
- expectedException.expectMessage("Both zkConnectString and URL are empty. zkConnectString=null, collection=collection, url=null");
-
- dao.connectToSolr(null, null, "collection");
- }
-
- @Test
- public void testConnectToSolrWithoutCollection() throws Exception {
- expectedException.expect(Exception.class);
- expectedException.expectMessage("For solr, collection name is mandatory. zkConnectString=zk_connect_string, collection=null, url=url");
-
- dao.connectToSolr("url", "zk_connect_string", null);
- }
-
- // ---------------------------------------------------------- checkSolrStatus ----------------------------------------------------------
-
- @Test
- public void testCheckSolrStatus() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
-
- NamedList<Object> response = new NamedList<Object>();
- NamedList<Object> header = new NamedList<Object>();
- header.add("status", 0);
- response.add("responseHeader", header);
- response.add("collections", new ArrayList<String>());
-
- EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
- EasyMock.replay(mockSolrClient);
-
- dao.solrClient = mockSolrClient;
-
- boolean status = dao.checkSolrStatus(10000);
- Assert.assertTrue(status);
-
- EasyMock.verify(mockSolrClient);
- }
-
- @Test
- public void testCheckSolrStatusNotSuccessful() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
- EasyMock.replay(mockSolrClient);
-
- dao.solrClient = mockSolrClient;
-
- boolean status = dao.checkSolrStatus(10000);
- Assert.assertFalse(status);
-
- EasyMock.verify(mockSolrClient);
- }
-
- // ------------------------------------------------------------- setupAlias ------------------------------------------------------------
-
- @Test
- public void testSetupAlias() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
- CloudSolrClient mockSolrClouldClient = EasyMock.strictMock(CloudSolrClient.class);
-
- NamedList<Object> response = new NamedList<Object>();
- NamedList<Object> header = new NamedList<Object>();
- header.add("status", 0);
- response.add("responseHeader", header);
- response.add("collections", Arrays.asList("collection1", "collection2"));
-
- EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
- EasyMock.expect(mockSolrClouldClient.request(EasyMock.anyObject(CollectionAdminRequest.CreateAlias.class), EasyMock.anyString())).andReturn(response);
- mockSolrClouldClient.setDefaultCollection("alias_name"); EasyMock.expectLastCall();
-
- EasyMock.replay(mockSolrClient, mockSolrClouldClient);
-
- dao.isZkConnectString = true;
- dao.solrClient = mockSolrClient;
- dao.solrClouldClient = mockSolrClouldClient;
- dao.collectionName = "test_collection";
-
- dao.setupAlias("alias_name", Arrays.asList("collection1", "collection2"));
-
- Thread.sleep(1000);
-
- EasyMock.verify(mockSolrClient, mockSolrClouldClient);
- }
-
- // ---------------------------------------------------------- setupCollections ---------------------------------------------------------
-
- @Test
- public void testCreateCollectionsDontSplitPopulate() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
-
- NamedList<Object> response = new NamedList<Object>();
- NamedList<Object> header = new NamedList<Object>();
- header.add("status", 0);
- response.add("responseHeader", header);
- response.add("collections", new ArrayList<String>());
-
- EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
- EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.Create.class), EasyMock.anyString())).andReturn(response);
- EasyMock.replay(mockSolrClient);
-
- dao.isZkConnectString = true;
- dao.solrClient = mockSolrClient;
- dao.collectionName = "test_collection";
-
- dao.setupCollections("none", "configName", 1, 1, true);
-
- EasyMock.verify(mockSolrClient);
- }
-
- @Test
- public void testCreateCollectionsSplitDontPopulate() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
-
- NamedList<Object> response = new NamedList<Object>();
- NamedList<Object> header = new NamedList<Object>();
- header.add("status", 0);
- response.add("responseHeader", header);
- response.add("collections", new ArrayList<String>());
-
- EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
- EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.Create.class), EasyMock.anyString())).andReturn(response);
- EasyMock.replay(mockSolrClient);
-
- dao.isZkConnectString = true;
- dao.solrClient = mockSolrClient;
-
- dao.setupCollections("1", "configName", 3, 1, false);
-
- EasyMock.verify(mockSolrClient);
- }
-
- // -------------------------------------------------------------- process --------------------------------------------------------------
-
- @Test
- public void testProcess() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
- EasyMock.expect(mockSolrClient.query(EasyMock.anyObject(SolrQuery.class), EasyMock.eq(METHOD.POST))).andReturn(new QueryResponse());
- EasyMock.replay(mockSolrClient);
-
- dao.solrClient = mockSolrClient;
-
- dao.process(new SolrQuery());
-
- EasyMock.verify(mockSolrClient);
- }
-
- @Test
- public void testProcessNoConnection() throws Exception {
- expectedException.expect(WebApplicationException.class);
-
- dao.process(new SolrQuery());
- }
-
- // ----------------------------------------------------------- add/removeDoc -----------------------------------------------------------
-
- @Test
- public void testAddDoc() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
-
- UpdateResponse updateResponse = new UpdateResponse();
- NamedList<Object> response = new NamedList<Object>();
- NamedList<Object> header = new NamedList<Object>();
- header.add("QTime", 1);
- response.add("responseHeader", header);
- updateResponse.setResponse(response);
-
- EasyMock.expect(mockSolrClient.add(EasyMock.anyObject(SolrInputDocument.class))).andReturn(updateResponse);
- EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
- EasyMock.replay(mockSolrClient);
-
- dao.solrClient = mockSolrClient;
-
- dao.addDocs(new SolrInputDocument());
-
- EasyMock.verify(mockSolrClient);
- }
-
- @Test
- public void testRemoveDoc() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
-
- UpdateResponse updateResponse = new UpdateResponse();
- NamedList<Object> response = new NamedList<Object>();
- NamedList<Object> header = new NamedList<Object>();
- header.add("QTime", 1);
- response.add("responseHeader", header);
- updateResponse.setResponse(response);
-
- EasyMock.expect(mockSolrClient.deleteByQuery(EasyMock.anyString())).andReturn(updateResponse);
- EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
- EasyMock.replay(mockSolrClient);
-
- dao.solrClient = mockSolrClient;
-
- dao.removeDoc("query");
-
- EasyMock.verify(mockSolrClient);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
deleted file mode 100644
index 3b01a19..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.dao;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
-import org.apache.ambari.logsearch.conf.SolrUserConfig;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrRequest.METHOD;
-import org.apache.solr.client.solrj.request.CollectionAdminRequest;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.NamedList;
-import org.easymock.Capture;
-import org.easymock.CaptureType;
-import org.easymock.EasyMock;
-import org.easymock.EasyMockSupport;
-import org.easymock.Mock;
-import org.easymock.TestSubject;
-import org.junit.Before;
-import org.junit.Test;
-
-import junit.framework.Assert;
-
-public class UserConfigSolrDaoTest {
-
- @TestSubject
- private UserConfigSolrDao dao = new UserConfigSolrDao();
-
- @Mock
- private SolrUserConfig configMock;
-
- @Mock
- private SolrKerberosConfig kerbConfigMock;
-
- @Before
- public void setUp() {
- EasyMockSupport.injectMocks(this);
- }
-
- @Test
- public void testUserConfigDaoPostConstructor() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
-
- NamedList<Object> requestResponse = new NamedList<Object>();
- NamedList<Object> requestResponseHeader = new NamedList<Object>();
- requestResponseHeader.add("status", 0);
- requestResponse.add("responseHeader", requestResponseHeader);
- requestResponse.add("collections", new ArrayList<String>());
-
- QueryResponse queryResponse = new QueryResponse();
-
- UpdateResponse updateResponse = new UpdateResponse();
- NamedList<Object> updateResponseContent = new NamedList<Object>();
- NamedList<Object> updateResponseHeader = new NamedList<Object>();
- updateResponseHeader.add("QTime", 1);
- updateResponseContent.add("responseHeader", updateResponseHeader);
- updateResponse.setResponse(updateResponseContent);
-
- EasyMock.expect(configMock.getSolrUrl()).andReturn(null).times(2);
- EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181").times(2);
- EasyMock.expect(configMock.getConfigName()).andReturn("test_history_logs_config_name").times(2);
- EasyMock.expect(configMock.getCollection()).andReturn("test_history_logs_collection").times(2);
- EasyMock.expect(configMock.getSplitInterval()).andReturn("none").times(2);
- EasyMock.expect(configMock.getNumberOfShards()).andReturn(123).times(2);
- EasyMock.expect(configMock.getReplicationFactor()).andReturn(234).times(2);
- EasyMock.expect(configMock.getLogLevels()).andReturn(Arrays.asList("TRACE")).times(2);
- EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false).times(2);
- EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file").times(2);
-
- Capture<CollectionAdminRequest.Create> captureCreateRequest = EasyMock.newCapture(CaptureType.LAST);
- Capture<SolrParams> captureSolrParams = EasyMock.newCapture(CaptureType.LAST);
- Capture<METHOD> captureMethod = EasyMock.newCapture(CaptureType.LAST);
- Capture<SolrInputDocument> captureSolrInputDocument = EasyMock.newCapture(CaptureType.LAST);
-
- EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(requestResponse);
- mockSolrClient.request(EasyMock.capture(captureCreateRequest), EasyMock.anyString()); EasyMock.expectLastCall().andReturn(requestResponse);
- mockSolrClient.query(EasyMock.capture(captureSolrParams), EasyMock.capture(captureMethod)); EasyMock.expectLastCall().andReturn(queryResponse);
- mockSolrClient.add(EasyMock.capture(captureSolrInputDocument)); EasyMock.expectLastCall().andReturn(updateResponse);
- EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
- EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
-
- dao.postConstructor();
- dao.solrClient = mockSolrClient;
- dao.isZkConnectString = true;
-
- dao.postConstructor();
- EasyMock.verify(mockSolrClient);
-
- CollectionAdminRequest.Create createRequest = captureCreateRequest.getValue();
- Assert.assertEquals(createRequest.getConfigName(), "test_history_logs_config_name");
- Assert.assertEquals(createRequest.getReplicationFactor().intValue(), 234);
- Assert.assertEquals(createRequest.getCollectionName(), "test_history_logs_collection");
-
- SolrParams solrParams = captureSolrParams.getValue();
- Assert.assertEquals(solrParams.get("q"), "*:*");
- Assert.assertEquals(solrParams.get("fq"), "rowtype:log_feeder_config");
-
- METHOD method = captureMethod.getValue();
- Assert.assertEquals(method, METHOD.POST);
-
- SolrInputDocument solrInputDocument = captureSolrInputDocument.getValue();
- Assert.assertNotNull(solrInputDocument.getFieldValue("id"));
- Assert.assertEquals(solrInputDocument.getFieldValue("rowtype"), "log_feeder_config");
- Assert.assertEquals(solrInputDocument.getFieldValue("jsons"), "{\"filter\":{\"test_component2\":{\"label\":\"test_component2\",\"hosts\":[],\"defaultLevels\":[\"TRACE\"],\"overrideLevels\":[]},\"test_component1\":{\"label\":\"test_component1\",\"hosts\":[],\"defaultLevels\":[\"TRACE\"],\"overrideLevels\":[]}},\"id\":\"" + solrInputDocument.getFieldValue("id") + "\"}");
- Assert.assertEquals(solrInputDocument.getFieldValue("username"), "log_feeder_config");
- Assert.assertEquals(solrInputDocument.getFieldValue("filtername"), "log_feeder_config");
- }
-
- @Test
- public void testDeleteUserConfig() throws Exception {
- SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
-
- UpdateResponse updateResponse = new UpdateResponse();
- NamedList<Object> response = new NamedList<Object>();
- NamedList<Object> header = new NamedList<Object>();
- header.add("QTime", 1);
- response.add("responseHeader", header);
- updateResponse.setResponse(response);
-
- EasyMock.expect(configMock.getSolrUrl()).andReturn(null);
- EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181");
- EasyMock.expect(configMock.getConfigName()).andReturn("test_history_logs_config_name");
- EasyMock.expect(configMock.getCollection()).andReturn("test_history_logs_collection");
- EasyMock.expect(configMock.getSplitInterval()).andReturn("none");
- EasyMock.expect(configMock.getNumberOfShards()).andReturn(123);
- EasyMock.expect(configMock.getReplicationFactor()).andReturn(234);
- EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
- EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
-
- EasyMock.expect(mockSolrClient.deleteByQuery("id:test_id")).andReturn(updateResponse);
- EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
- EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
-
- dao.postConstructor();
- dao.solrClient = mockSolrClient;
- dao.isZkConnectString = true;
-
- dao.deleteUserConfig("test_id");
-
- EasyMock.verify(mockSolrClient, configMock, kerbConfigMock);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/docker/test-config/logsearch/logsearch.properties
----------------------------------------------------------------------
diff --git a/ambari-logsearch/docker/test-config/logsearch/logsearch.properties b/ambari-logsearch/docker/test-config/logsearch/logsearch.properties
index 2c83581..71c1a1c 100644
--- a/ambari-logsearch/docker/test-config/logsearch/logsearch.properties
+++ b/ambari-logsearch/docker/test-config/logsearch/logsearch.properties
@@ -22,8 +22,6 @@ logsearch.service.logs.split.interval.mins=15
logsearch.collection.service.logs.numshards=3
logsearch.collection.service.logs.replication.factor=2
-logsearch.service.logs.fields=logtime,level,event_count,ip,type,seq_num,path,file,line_number,host,log_message,id
-
# Audit logs
logsearch.solr.audit.logs.zk_connect_string=localhost:9983
logsearch.solr.collection.audit.logs=audit_logs
[4/6] ambari git commit: AMBARI-18310. Refactor logsearch portal code
- part 3 (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
index 02309fc..1d4f91f 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
@@ -21,18 +21,14 @@ package org.apache.ambari.logsearch.manager;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -40,10 +36,9 @@ import java.util.concurrent.CopyOnWriteArrayList;
import javax.inject.Inject;
import javax.ws.rs.core.Response;
-import org.apache.ambari.logsearch.common.ConfigHelper;
import org.apache.ambari.logsearch.common.LogSearchConstants;
import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.conf.SolrServiceLogConfig;
+import org.apache.ambari.logsearch.conf.SolrServiceLogPropsConfig;
import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
import org.apache.ambari.logsearch.graph.GraphDataGenerator;
import org.apache.ambari.logsearch.model.response.BarGraphData;
@@ -67,7 +62,6 @@ import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
import org.apache.ambari.logsearch.query.model.ServiceAnyGraphSearchCriteria;
import org.apache.ambari.logsearch.query.model.ServiceGraphSearchCriteria;
import org.apache.ambari.logsearch.query.model.ServiceLogExportSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceLogFileSearchCriteria;
import org.apache.ambari.logsearch.query.model.ServiceLogSearchCriteria;
import org.apache.ambari.logsearch.query.model.ServiceLogTruncatedSearchCriteria;
import org.apache.ambari.logsearch.solr.model.SolrComponentTypeLogData;
@@ -117,7 +111,7 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
@Inject
private GraphDataGenerator graphDataGenerator;
@Inject
- private SolrServiceLogConfig solrServiceLogConfig;
+ private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
public ServiceLogResponse searchLogs(ServiceLogSearchCriteria searchCriteria) {
String keyword = searchCriteria.getKeyword();
@@ -406,7 +400,7 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
return extensionTree;
}
- public NodeListResponse getTreeExtension(ServiceLogFileSearchCriteria searchCriteria) {
+ public NodeListResponse getTreeExtension(ServiceLogSearchCriteria searchCriteria) {
SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
solrQuery.setParam("event", "/getTreeExtension");
@@ -469,7 +463,7 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
return list;
}
- public NodeListResponse getHostListByComponent(ServiceLogFileSearchCriteria searchCriteria) {
+ public NodeListResponse getHostListByComponent(ServiceLogSearchCriteria searchCriteria) {
SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
solrQuery.setParam("event", "/service/hosts/components");
@@ -529,7 +523,7 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
}
}
- public NameValueDataListResponse getLogsLevelCount(ServiceLogFileSearchCriteria sc) {
+ public NameValueDataListResponse getLogsLevelCount(ServiceLogSearchCriteria sc) {
NameValueDataListResponse nameValueList = new NameValueDataListResponse();
SolrQuery query = queryGenerator.commonServiceFilterQuery(sc);
query.setParam("event", "/service/logs/levels/counts/namevalues");
@@ -1169,7 +1163,7 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
return dataList;
}
- extractValuesFromBuckets(jsonFacetResponse, "x", "y", histogramData);
+ serviceLogsSolrDao.extractValuesFromBuckets(jsonFacetResponse, "x", "y", histogramData);
Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
List<BarGraphData> graphDatas = new ArrayList<BarGraphData>();
@@ -1337,19 +1331,6 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
isNormalExcluded = true;
}
- String globalExcludeString = (String) searchCriteria
- .getParamValue("gEMessage");
- if (StringUtils.isBlank(globalExcludeString)) {
- globalExcludeString = "";
- }
-
- String globalExclude[] = globalExcludeString
- .split(LogSearchConstants.I_E_SEPRATOR);
-
- for (String exc : globalExclude) {
- excludeString = excludeString + ",\"" + exc + "\"";
- }
-
if (!StringUtils.isBlank(excludeString)) {
if (!isNormalExcluded) {
excludeString = excludeString.replaceFirst(",", "");
@@ -1387,7 +1368,7 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
}
}
- public NodeListResponse getComponentListWithLevelCounts(ServiceLogFileSearchCriteria searchCriteria) {
+ public NodeListResponse getComponentListWithLevelCounts(ServiceLogSearchCriteria searchCriteria) {
SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
solrQuery.setParam("event", "/service/logs/components/levels/counts");
@@ -1517,95 +1498,8 @@ public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceL
return nameValueList;
}
- public String getServiceLogsFieldsName() {
- List<String> fieldsNames = solrServiceLogConfig.getFields();
- if (fieldsNames.size() > 0) {
-
- List<String> uiFieldNames = new ArrayList<String>();
- String temp = null;
- for (String field : fieldsNames) {
- temp = solrServiceLogConfig.getSolrAndUiColumns().get(field + LogSearchConstants.SOLR_SUFFIX);
- if (temp == null){
- uiFieldNames.add(field);
- }else{
- uiFieldNames.add(temp);
- }
- }
- return convertObjToString(uiFieldNames);
-
- }
- throw RESTErrorUtil.createRESTException(
- "No field name found in property file",
- MessageEnums.DATA_NOT_FOUND);
-
- }
-
public String getServiceLogsSchemaFieldsName() {
-
- List<String> fieldNames = new ArrayList<String>();
- String excludeArray[] = Arrays.copyOf(solrServiceLogConfig.getExcludeColumnList().toArray(),
- solrServiceLogConfig.getExcludeColumnList().size(), String[].class);
-
- HashMap<String, String> uiFieldColumnMapping = new LinkedHashMap<String, String>();
- ConfigHelper.getSchemaFieldsName(excludeArray, fieldNames,serviceLogsSolrDao);
-
- for (String fieldName : fieldNames) {
- String uiField = solrServiceLogConfig.getSolrAndUiColumns().get(fieldName + LogSearchConstants.SOLR_SUFFIX);
- if (uiField != null) {
- uiFieldColumnMapping.put(fieldName, uiField);
- } else {
- uiFieldColumnMapping.put(fieldName, fieldName);
- }
- }
-
- HashMap<String, String> uiFieldColumnMappingSorted = new LinkedHashMap<String, String>();
- uiFieldColumnMappingSorted.put(LogSearchConstants.SOLR_LOG_MESSAGE, LogSearchConstants.SOLR_LOG_MESSAGE);
-
- Iterator<Entry<String, String>> it = BizUtil
- .sortHashMapByValues(uiFieldColumnMapping).entrySet().iterator();
- while (it.hasNext()) {
- @SuppressWarnings("rawtypes")
- Map.Entry pair = (Map.Entry) it.next();
- uiFieldColumnMappingSorted.put("" + pair.getKey(), "" + pair.getValue());
- }
-
- return convertObjToString(uiFieldColumnMappingSorted);
-
- }
-
- @SuppressWarnings("unchecked")
- public void extractValuesFromBuckets(
- SimpleOrderedMap<Object> jsonFacetResponse, String outerField,
- String innerField, List<BarGraphData> histogramData) {
- NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse
- .get(outerField);
- ArrayList<Object> stackBuckets = (ArrayList<Object>) stack
- .get("buckets");
- for (Object temp : stackBuckets) {
- BarGraphData vBarGraphData = new BarGraphData();
-
- SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
- String name = ((String) level.getVal(0)).toUpperCase();
- vBarGraphData.setName(name);
-
- Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
- vBarGraphData.setDataCount(vNameValues);
- ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level
- .get(innerField)).get("buckets");
- for (Object temp1 : levelBuckets) {
- SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
- String value = DateUtil
- .convertDateWithMillisecondsToSolrDate((Date) countValue
- .getVal(0));
-
- String count = "" + countValue.getVal(1);
- NameValueData vNameValue = new NameValueData();
- vNameValue.setName(value);
- vNameValue.setValue(count);
- vNameValues.add(vNameValue);
- }
- histogramData.add(vBarGraphData);
- }
+ return convertObjToString(serviceLogsSolrDao.schemaFieldNameMap);
}
public BarGraphDataListResponse getAnyGraphData(ServiceAnyGraphSearchCriteria searchCriteria) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
index 7430770..6772138 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
@@ -53,7 +53,6 @@ import javax.inject.Inject;
public class UserConfigManager extends JsonManagerBase {
private static final Logger logger = Logger.getLogger(UserConfigManager.class);
-
@Inject
private UserConfigSolrDao userConfigSolrDao;
@Inject
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileParamDefinition.java
deleted file mode 100644
index c355989..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileParamDefinition.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.COMPONENT_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.HOST_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.LOG_TYPE_D;
-
-
-public interface LogFileParamDefinition {
-
- String getComponent();
-
- @ApiParam(value = COMPONENT_D, name = LogSearchConstants.REQUEST_PARAM_COMPONENT)
- void setComponent(String component);
-
- String getHost();
-
- @ApiParam(value = HOST_D, name = LogSearchConstants.REQUEST_PARAM_HOST)
- void setHost(String host);
-
- String getLogType();
-
- @ApiParam(value = LOG_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_LOG_TYPE)
- void setLogType(String logType);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileTailParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileTailParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileTailParamDefinition.java
deleted file mode 100644
index a527c48..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileTailParamDefinition.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.TAIL_SIZE_D;
-
-public interface LogFileTailParamDefinition {
-
- String getTailSize();
-
- @ApiParam(value = TAIL_SIZE_D, name = LogSearchConstants.REQUEST_PARAM_TAIL_SIZE)
- void setTailSize(String tailSize);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
index e503ff5..e44de35 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
@@ -20,10 +20,7 @@ package org.apache.ambari.logsearch.model.request;
import io.swagger.annotations.ApiParam;
import org.apache.ambari.logsearch.common.LogSearchConstants;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.COLUMN_QUERY_D;
import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.I_MESSAGE_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.G_E_MESSAGE_D;
import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.MUST_BE_D;
import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.MUST_NOT_D;
import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.INCLUDE_QUERY_D;
@@ -31,21 +28,11 @@ import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.EX
public interface LogParamDefinition {
- String getColumnQuery();
-
- @ApiParam(value = COLUMN_QUERY_D, name = LogSearchConstants.REQUEST_PARAM_COLUMN_QUERY)
- void setColumnQuery(String columnQuery);
-
String getiMessage();
@ApiParam(value = I_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_I_MESSAGE)
void setiMessage(String iMessage);
- String getgEMessage();
-
- @ApiParam(value = G_E_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_G_E_MESSAGE)
- void setgEMessage(String gEMessage);
-
String getMustBe();
@ApiParam(value = MUST_BE_D, name = LogSearchConstants.REQUEST_PARAM_MUST_BE)
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogFileParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogFileParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogFileParamDefinition.java
deleted file mode 100644
index a266b3e..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogFileParamDefinition.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.HOST_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.COMPONENT_D;
-
-public interface ServiceLogFileParamDefinition {
-
- String getHostLogFile();
-
- @ApiParam(value = HOST_D, name = LogSearchConstants.REQUEST_PARAM_HOST_LOG_FILE)
- void setHostLogFile(String hostLogFile);
-
- String getComponentLogFile();
-
- @ApiParam(value = COMPONENT_D, name = LogSearchConstants.REQUEST_PARAM_COMPONENT_LOG_FILE)
- void setComponentLogFile(String componentLogFile);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
index f280ac2..abc1f08 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
@@ -22,8 +22,6 @@ import io.swagger.annotations.ApiParam;
import org.apache.ambari.logsearch.common.LogSearchConstants;
import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.LEVEL_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.ADVANCED_SEARCH_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.TREE_PARAMS_D;
import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.E_MESSAGE_D;
import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.G_MUST_NOT_D;
import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.HOST_NAME_D;
@@ -38,26 +36,11 @@ public interface ServiceLogParamDefinition {
@ApiParam(value = LEVEL_D, name = LogSearchConstants.REQUEST_PARAM_LEVEL)
void setLevel(String level);
- String getAdvancedSearch();
-
- @ApiParam(value = ADVANCED_SEARCH_D, name = LogSearchConstants.REQUEST_PARAM_ADVANCED_SEARCH)
- void setAdvancedSearch(String advancedSearch);
-
- String getTreeParams();
-
- @ApiParam(value = TREE_PARAMS_D, name = LogSearchConstants.REQUEST_PARAM_TREE_PARAMS)
- void setTreeParams(String treeParams);
-
String geteMessage();
@ApiParam(value = E_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
void seteMessage(String eMessage);
- String getgMustNot();
-
- @ApiParam(value = G_MUST_NOT_D, name = LogSearchConstants.REQUEST_PARAM_G_MUST_NOT)
- void setgMustNot(String gMustNot);
-
String getHostName();
@ApiParam(value = HOST_NAME_D, name = LogSearchConstants.REQUEST_PARAM_HOST_NAME)
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
index 5a96991..1371350 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
@@ -25,15 +25,10 @@ import org.apache.ambari.logsearch.model.request.LogParamDefinition;
import javax.ws.rs.QueryParam;
public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
- @QueryParam(LogSearchConstants.REQUEST_PARAM_COLUMN_QUERY)
- private String columnQuery;
@QueryParam(LogSearchConstants.REQUEST_PARAM_I_MESSAGE)
private String iMessage;
- @QueryParam(LogSearchConstants.REQUEST_PARAM_G_E_MESSAGE)
- private String gEMessage;
-
@QueryParam(LogSearchConstants.REQUEST_PARAM_MUST_BE)
private String mustBe;
@@ -47,16 +42,6 @@ public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
private String includeQuery;
@Override
- public String getColumnQuery() {
- return columnQuery;
- }
-
- @Override
- public void setColumnQuery(String columnQuery) {
- this.columnQuery = columnQuery;
- }
-
- @Override
public String getiMessage() {
return iMessage;
}
@@ -67,16 +52,6 @@ public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
}
@Override
- public String getgEMessage() {
- return gEMessage;
- }
-
- @Override
- public void setgEMessage(String gEMessage) {
- this.gEMessage = gEMessage;
- }
-
- @Override
public String getMustBe() {
return mustBe;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
index ba4f4a8..5770ba6 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
@@ -31,18 +31,9 @@ public class BaseServiceLogRequest extends BaseLogRequest
@QueryParam(LogSearchConstants.REQUEST_PARAM_LEVEL)
private String level;
- @QueryParam(LogSearchConstants.REQUEST_PARAM_ADVANCED_SEARCH)
- private String advancedSearch;
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_TREE_PARAMS)
- private String treeParams;
-
@QueryParam(LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
private String eMessage;
- @QueryParam(LogSearchConstants.REQUEST_PARAM_G_MUST_NOT)
- private String gMustNot;
-
@QueryParam(LogSearchConstants.REQUEST_PARAM_HOST_NAME)
private String hostName;
@@ -75,26 +66,6 @@ public class BaseServiceLogRequest extends BaseLogRequest
}
@Override
- public String getAdvancedSearch() {
- return advancedSearch;
- }
-
- @Override
- public void setAdvancedSearch(String advancedSearch) {
- this.advancedSearch = advancedSearch;
- }
-
- @Override
- public String getTreeParams() {
- return treeParams;
- }
-
- @Override
- public void setTreeParams(String treeParams) {
- this.treeParams = treeParams;
- }
-
- @Override
public String geteMessage() {
return eMessage;
}
@@ -105,16 +76,6 @@ public class BaseServiceLogRequest extends BaseLogRequest
}
@Override
- public String getgMustNot() {
- return gMustNot;
- }
-
- @Override
- public void setgMustNot(String gMustNot) {
- this.gMustNot = gMustNot;
- }
-
- @Override
public String getHostName() {
return hostName;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileRequest.java
deleted file mode 100644
index 78c5b33..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileRequest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request.impl;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.LogFileParamDefinition;
-import org.apache.ambari.logsearch.model.request.SearchRequest;
-
-import javax.ws.rs.QueryParam;
-
-public class LogFileRequest implements SearchRequest, LogFileParamDefinition {
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_COMPONENT)
- private String component;
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_HOST)
- private String host;
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_LOG_TYPE)
- private String logType;
-
- @Override
- public String getComponent() {
- return component;
- }
-
- @Override
- public void setComponent(String component) {
- this.component = component;
- }
-
- @Override
- public String getHost() {
- return host;
- }
-
- @Override
- public void setHost(String host) {
- this.host = host;
- }
-
- @Override
- public String getLogType() {
- return logType;
- }
-
- @Override
- public void setLogType(String logType) {
- this.logType = logType;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileTailRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileTailRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileTailRequest.java
deleted file mode 100644
index d5b91ab..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileTailRequest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request.impl;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.LogFileTailParamDefinition;
-
-import javax.ws.rs.QueryParam;
-
-public class LogFileTailRequest extends LogFileRequest implements LogFileTailParamDefinition {
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_TAIL_SIZE)
- private String tailSize;
-
- @Override
- public String getTailSize() {
- return tailSize;
- }
-
- @Override
- public void setTailSize(String tailSize) {
- this.tailSize = tailSize;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceGraphRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceGraphRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceGraphRequest.java
index 1618aa1..57884b7 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceGraphRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceGraphRequest.java
@@ -23,7 +23,7 @@ import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
import javax.ws.rs.QueryParam;
-public class ServiceGraphRequest extends ServiceLogFileRequest implements UnitParamDefinition {
+public class ServiceGraphRequest extends ServiceLogRequest implements UnitParamDefinition {
@QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
private String unit;
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogExportRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogExportRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogExportRequest.java
index 6ae0dc9..16300ce 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogExportRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogExportRequest.java
@@ -24,7 +24,7 @@ import org.apache.ambari.logsearch.model.request.UtcOffsetParamDefinition;
import javax.ws.rs.QueryParam;
-public class ServiceLogExportRequest extends ServiceLogFileRequest implements FormatParamDefinition, UtcOffsetParamDefinition {
+public class ServiceLogExportRequest extends ServiceLogRequest implements FormatParamDefinition, UtcOffsetParamDefinition {
@QueryParam(LogSearchConstants.REQUEST_PARAM_FORMAT)
private String format;
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogFileRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogFileRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogFileRequest.java
deleted file mode 100644
index 6c7078a..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogFileRequest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.model.request.impl;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.ServiceLogFileParamDefinition;
-
-import javax.ws.rs.QueryParam;
-
-public class ServiceLogFileRequest extends BaseServiceLogRequest implements ServiceLogFileParamDefinition {
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_HOST_LOG_FILE)
- private String hostLogFile;
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_COMPONENT_LOG_FILE)
- private String componentLogFile;
-
- @Override
- public String getHostLogFile() {
- return hostLogFile;
- }
-
- @Override
- public void setHostLogFile(String hostLogFile) {
- this.hostLogFile = hostLogFile;
- }
-
- @Override
- public String getComponentLogFile() {
- return componentLogFile;
- }
-
- @Override
- public void setComponentLogFile(String componentLogFile) {
- this.componentLogFile = componentLogFile;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogRequest.java
index 9a46de3..fe36ad8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogRequest.java
@@ -24,7 +24,7 @@ import org.apache.ambari.logsearch.model.request.ServiceLogSearchParamDefinition
import javax.ws.rs.QueryParam;
-public class ServiceLogRequest extends ServiceLogFileRequest implements ServiceLogSearchParamDefinition, LastPageParamDefinition {
+public class ServiceLogRequest extends BaseServiceLogRequest implements ServiceLogSearchParamDefinition, LastPageParamDefinition {
@QueryParam(LogSearchConstants.REQUEST_PARAM_KEYWORD)
private String keyWord;
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
index 516c328..8067896 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
@@ -23,7 +23,7 @@ import org.apache.ambari.logsearch.model.request.LogTruncatedParamDefinition;
import javax.ws.rs.QueryParam;
-public class ServiceLogTruncatedRequest extends ServiceLogFileRequest implements LogTruncatedParamDefinition {
+public class ServiceLogTruncatedRequest extends ServiceLogRequest implements LogTruncatedParamDefinition {
@QueryParam(LogSearchConstants.REQUEST_PARAM_ID)
private String id;
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
index 9ea29c2..8095faf 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
@@ -23,14 +23,11 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
-import java.util.regex.Pattern;
-import org.apache.ambari.logsearch.common.ConfigHelper;
import org.apache.ambari.logsearch.common.LogSearchConstants;
import org.apache.ambari.logsearch.common.PropertiesHelper;
-import org.apache.ambari.logsearch.conf.SolrAuditLogConfig;
-import org.apache.ambari.logsearch.conf.SolrServiceLogConfig;
-import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
+import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
+import org.apache.ambari.logsearch.conf.SolrServiceLogPropsConfig;
import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
import org.apache.ambari.logsearch.query.model.SearchCriteria;
@@ -57,20 +54,18 @@ public class QueryGeneration extends QueryGenerationBase {
private static Logger logger = Logger.getLogger(QueryGeneration.class);
@Inject
- private SolrServiceLogConfig solrServiceLogConfig;
+ private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
@Inject
- private SolrAuditLogConfig solrAuditLogConfig;
+ private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
public SolrQuery commonServiceFilterQuery(CommonServiceLogSearchCriteria searchCriteria) {
LogType logType = LogType.SERVICE;
SolrQuery solrQuery = new SolrQuery();
- String advQuery = (String) searchCriteria.getParamValue("advanceSearch"); // TODO: check these are used from the UI or not
- String gEmessage = (String) searchCriteria.getParamValue("gEMessage");
+ // TODO: check these are used from the UI or not
String globalExcludeComp = (String) searchCriteria.getParamValue("gMustNot");
String unselectedComp = (String) searchCriteria.getParamValue("unselectComp");
- String treeParams = searchCriteria.getTreeParams();
String givenQuery = (String) searchCriteria.getParamValue("q");
String level = searchCriteria.getLevel();
String startTime = searchCriteria.getFrom();
@@ -82,37 +77,15 @@ public class QueryGeneration extends QueryGenerationBase {
String urlHostName = searchCriteria.getHostName();
String urlComponentName = searchCriteria.getComponentName();
String file_name = searchCriteria.getFileName();
- // build advance query
- if (!StringUtils.isBlank(advQuery)) {
- String advQueryParameters[] = advQuery.split(Pattern.quote("}{"));
- SolrQuery advSolrQuery = new SolrQuery();
- for (String queryParam : advQueryParameters) {
- String params[] = queryParam.split(Pattern.quote("="));
- if (params.length > 1)
- advSolrQuery.setParam(params[0], params[1]);
- }
- setFilterClauseWithFieldName(advSolrQuery, level, LogSearchConstants.SOLR_LEVEL, "", Condition.OR);
- setSingleRangeFilter(advSolrQuery, LogSearchConstants.LOGTIME, startTime, endTime);
- setFilterClauseWithFieldName(advSolrQuery, unselectedComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR,
- Condition.AND);
- setFilterClauseWithFieldName(advSolrQuery, selectedComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.NO_OPERATOR,
- Condition.OR);
-
- setPagination(advSolrQuery, searchCriteria);
-
- return advSolrQuery;
- }
SolrUtil.setMainQuery(solrQuery, givenQuery);
setSingleRangeFilter(solrQuery, LogSearchConstants.LOGTIME, startTime, endTime);
addFilter(solrQuery, selectedComp, LogSearchConstants.SOLR_COMPONENT, Condition.OR);
- addFilterQueryFromArray(solrQuery, treeParams, LogSearchConstants.SOLR_HOST, Condition.OR);
setFilterClauseWithFieldName(solrQuery, level, LogSearchConstants.SOLR_LEVEL, LogSearchConstants.NO_OPERATOR, Condition.OR);
setFilterClauseForSolrSearchableString(solrQuery, iMessage, Condition.OR, LogSearchConstants.NO_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
- setFilterClauseForSolrSearchableString(solrQuery, gEmessage, Condition.AND, LogSearchConstants.MINUS_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
setFilterClauseForSolrSearchableString(solrQuery, eMessage, Condition.AND, LogSearchConstants.MINUS_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
applyLogFileFilter(solrQuery, searchCriteria);
@@ -156,35 +129,24 @@ public class QueryGeneration extends QueryGenerationBase {
private void setUserSpecificFilter(SearchCriteria searchCriteria, SolrQuery solrQuery, String paramName, String operation,
LogType logType) {
String queryString = (String) searchCriteria.getParamValue(paramName);
- String columnQuery = (String) searchCriteria.getParamValue(LogSearchConstants.COLUMN_QUERY);
if (StringUtils.isBlank(queryString)) {
queryString = null;
}
- if (!StringUtils.isBlank(columnQuery) && StringUtils.isBlank(queryString) && !paramName.equals(LogSearchConstants.EXCLUDE_QUERY)) {
- queryString = columnQuery;
- }
List<String> conditionQuries = new ArrayList<String>();
List<String> referalConditionQuries = new ArrayList<String>();
List<String> elments = new ArrayList<String>();
List<HashMap<String, Object>> queryList = JSONUtil.jsonToMapObjectList(queryString);
if (queryList != null && queryList.size() > 0) {
- if (!StringUtils.isBlank(columnQuery) && !columnQuery.equals(queryString) && !paramName.equals(LogSearchConstants.EXCLUDE_QUERY)) {
- List<HashMap<String, Object>> columnQueryList = JSONUtil.jsonToMapObjectList(columnQuery);
- if (columnQueryList != null && columnQueryList.size() > 0) {
- queryList.addAll(columnQueryList);
- }
- }
for (HashMap<String, Object> columnListMap : queryList) {
String orQuery = "";
StringBuilder field = new StringBuilder();
if (columnListMap != null) {
for (String key : columnListMap.keySet()) {
- if (!StringUtils.isBlank(key)) {
- String originalKey = getOriginalKey(key, logType);
- String value = getOriginalValue(originalKey, "" + columnListMap.get(key));
- orQuery = putWildCardByType(value, originalKey, logType);
+ if (!StringUtils.isBlank(key)) {;
+ String value = getOriginalValue(key, "" + columnListMap.get(key));
+ orQuery = putWildCardByType(value, key, logType);
if (StringUtils.isBlank(orQuery)) {
- logger.debug("Removing invalid filter for key :"+originalKey +" and value :" +value );
+ logger.debug("Removing invalid filter for key :"+key +" and value :" +value );
continue;
}
boolean isSame = false;
@@ -193,17 +155,17 @@ public class QueryGeneration extends QueryGenerationBase {
}
if (isSame && !operation.equals(LogSearchConstants.EXCLUDE_QUERY)) {
for (String tempCondition : conditionQuries) {
- if (tempCondition.contains(originalKey)) {
+ if (tempCondition.contains(key)) {
String newCondtion = tempCondition + " " + Condition.OR.name() + " " + orQuery;
referalConditionQuries.remove(tempCondition);
referalConditionQuries.add(newCondtion);
}
}
- conditionQuries.removeAll(conditionQuries);
+ conditionQuries.clear();
conditionQuries.addAll(referalConditionQuries);
} else {
- conditionQuries.add(orQuery.toString());
- referalConditionQuries.add(orQuery.toString());
+ conditionQuries.add(orQuery);
+ referalConditionQuries.add(orQuery);
}
field.append(key);
elments.add(field.toString());
@@ -213,7 +175,7 @@ public class QueryGeneration extends QueryGenerationBase {
}
}
if (!referalConditionQuries.isEmpty() && !StringUtils.isBlank(operation)) {
- if (operation.equals(LogSearchConstants.INCLUDE_QUERY) || operation.equals(LogSearchConstants.COLUMN_QUERY)) {
+ if (operation.equals(LogSearchConstants.INCLUDE_QUERY)) {
for (String filter : referalConditionQuries) {
if (!StringUtils.isBlank(filter)) {
solrQuery.addFilterQuery(filter);
@@ -235,17 +197,12 @@ public class QueryGeneration extends QueryGenerationBase {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery("*:*");
- String globalExcludeComp = (String) searchCriteria.getParamValue("gMustNot"); // TODO: check this are used from UI or not
- String unselectedComp = (String) searchCriteria.getParamValue("unselectComp");
-
String startTime = searchCriteria.getStartTime();
String endTime = searchCriteria.getEndTime();
String selectedComp = searchCriteria.getMustBe();
setFilterClauseWithFieldName(solrQuery, selectedComp, LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.NO_OPERATOR, Condition.OR);
setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.INCLUDE_QUERY, LogSearchConstants.INCLUDE_QUERY, logType);
setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.EXCLUDE_QUERY, LogSearchConstants.EXCLUDE_QUERY, logType);
- setFilterClauseWithFieldName(solrQuery, globalExcludeComp, LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
- setFilterClauseWithFieldName(solrQuery, unselectedComp, LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
setSingleRangeFilter(solrQuery, LogSearchConstants.AUDIT_EVTTIME, startTime, endTime);
setPagination(solrQuery, searchCriteria);
try {
@@ -266,11 +223,11 @@ public class QueryGeneration extends QueryGenerationBase {
SolrDaoBase solrDaoBase = null;
switch (logType) {
case AUDIT:
- fieldType = auditSolrDao.schemaFieldsNameMap.get(key);
+ fieldType = auditSolrDao.schemaFieldNameMap.get(key);
solrDaoBase = auditSolrDao;
break;
case SERVICE:
- fieldType = serviceLogsSolrDao.schemaFieldsNameMap.get(key);
+ fieldType = serviceLogsSolrDao.schemaFieldNameMap.get(key);
solrDaoBase = serviceLogsSolrDao;
if (key.equalsIgnoreCase(LogSearchConstants.SOLR_LOG_MESSAGE)) {
return SolrUtil.escapeForLogMessage(key, str);
@@ -338,7 +295,7 @@ public class QueryGeneration extends QueryGenerationBase {
}
try {
String propertyFieldMappings[] = solrValue.split(LogSearchConstants.LIST_SEPARATOR);
- if (propertyFieldMappings != null && propertyFieldMappings.length > 0) {
+ if (propertyFieldMappings.length > 0) {
HashMap<String, String> propertyFieldValue = new HashMap<String, String>();
for (String temp : propertyFieldMappings) {
if (!StringUtils.isBlank(temp)) {
@@ -361,24 +318,7 @@ public class QueryGeneration extends QueryGenerationBase {
return value;
}
- private String getOriginalKey(String key, LogType logType) {
- String originalKey;
- switch (logType) {
- case AUDIT:
- originalKey = solrAuditLogConfig.getSolrAndUiColumns().get(key + LogSearchConstants.UI_SUFFIX);
- break;
- case SERVICE:
- originalKey = solrServiceLogConfig.getSolrAndUiColumns().get(key + LogSearchConstants.UI_SUFFIX);
- break;
- default:
- originalKey = null;
- }
- if (StringUtils.isBlank(originalKey)) {
- return key;
- }
- return originalKey;
- }
-
+
private boolean checkTokenizer(String fieldType, Class tokenizerFactoryClass, SolrDaoBase solrDaoBase) {
HashMap<String, Object> fieldTypeMap = SolrUtil.getFieldTypeInfoMap(fieldType,solrDaoBase);
HashMap<String, Object> analyzer = (HashMap<String, Object>) fieldTypeMap.get("analyzer");
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
index d7d30d7..536f41c 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
@@ -271,34 +271,6 @@ public abstract class QueryGenerationBase {
return "";
}
- protected void addFilterQueryFromArray(SolrQuery solrQuery, String jsonArrStr, String solrFieldName, Condition condition) {
- if (!StringUtils.isBlank(jsonArrStr) && condition != null && solrQuery != null) {
- Gson gson = new Gson();
- String[] arr = null;
- try {
- arr = gson.fromJson(jsonArrStr, String[].class);
- } catch (Exception exception) {
- logger.error("Invaild json array:" + jsonArrStr);
- return;
- }
- String query;;
- switch (condition) {
- case OR:
- query = SolrUtil.orList(solrFieldName, arr,"");
- break;
- case AND:
- query = SolrUtil.andList(solrFieldName, arr, "");
- break;
- default:
- query=null;
- logger.error("Invalid condition :" + condition.name());
- }
- if (!StringUtils.isBlank(query)) {
- solrQuery.addFilterQuery(query);
- }
- }
- }
-
protected void addFilter(SolrQuery solrQuery, String paramValue, String solrFieldName, Condition condition) {
String filterQuery = buildListQuery(paramValue, solrFieldName, condition);
if (!StringUtils.isBlank(filterQuery)) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/SearchCriteriaConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/SearchCriteriaConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/SearchCriteriaConstants.java
index c67d3cd..3c4df76 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/SearchCriteriaConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/SearchCriteriaConstants.java
@@ -45,21 +45,13 @@ public class SearchCriteriaConstants {
public static final String PARAM_FROM = "from";
public static final String PARAM_TO = "to";
- public static final String PARAM_LOG_FILE_COMPONENT = "component";
- public static final String PARAM_LOG_FILE_HOST = "host";
- public static final String PARAM_LOG_FILE_TYPE = "logType";
- public static final String PARAM_LOG_TAIL_SIZE = "tailSize";
-
public static final String PARAM_COMPONENT_NAME = "component_name";
public static final String PARAM_HOST_NAME = "host_name";
public static final String PARAM_FILE_NAME = "file_name";
public static final String PARAM_BUNDLE_ID = "bundle_id";
public static final String PARAM_SELECT_COMP = "selectComp";
public static final String PARAM_LEVEL = "level";
- public static final String PARAM_TREE_PARAMS = "treeParams";
- public static final String PARAM_HOST_LOG_FILE = "hostLogFile";
- public static final String PARAM_COMPONENT_LOG_FILE = "compLogFile";
public static final String PARAM_ID = "id";
public static final String PARAM_SCROLL_TYPE = "scrollType";
public static final String PARAM_NUMBER_ROWS = "numberRows";
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
index e25eb51..d40c5a1 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
@@ -31,10 +31,6 @@ public abstract class AbstractCommonAuditLogRequestConverter<SOURCE extends Base
public RESULT convertToSearchCriteria(SOURCE request) {
RESULT criteria = createCriteria(request);
criteria.addParam("q", request.getQuery());
- criteria.addParam("columnQuery", StringEscapeUtils.unescapeXml(request.getColumnQuery()));
- criteria.addParam("gEMessage", StringEscapeUtils.unescapeXml(request.getgEMessage()));
- criteria.setIncludeMessage(StringEscapeUtils.unescapeXml(request.getiMessage()));
- criteria.setExcludeMessage(StringEscapeUtils.unescapeXml(request.getgEMessage()));
criteria.setMustBe(request.getMustBe());
criteria.setMustNot(request.getMustNot());
criteria.setExcludeQuery(StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
index 2282c11..8e91584 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
@@ -29,13 +29,9 @@ public abstract class AbstractCommonServiceLogRequestConverter<SOURCE extends Ba
public RESULT convertToSearchCriteria(SOURCE request) {
RESULT criteria = createCriteria(request);
// TODO: check are these used from the UI or not?
- criteria.addParam("advanceSearch", StringEscapeUtils.unescapeXml(request.getAdvancedSearch()));
criteria.addParam("q", request.getQuery());
- criteria.addParam("gMustNot", request.getgMustNot());
- criteria.addParam("gEMessage", StringEscapeUtils.unescapeXml(request.getgEMessage()));
criteria.addParam("unselectComp", request.getMustNot());
- criteria.setTreeParams(StringEscapeUtils.unescapeHtml(request.getTreeParams()));
criteria.setLevel(request.getLevel());
criteria.setFrom(request.getFrom());
criteria.setTo(request.getTo());
@@ -44,8 +40,6 @@ public abstract class AbstractCommonServiceLogRequestConverter<SOURCE extends Ba
criteria.setHostName(request.getHostName());
criteria.setComponentName(request.getComponentName());
criteria.setFileName(request.getFileName());
- criteria.setIncludeMessage(StringEscapeUtils.unescapeXml(request.getiMessage()));
- criteria.setExcludeMessage(StringEscapeUtils.unescapeXml(request.getgEMessage()));
criteria.setStartTime(request.getStartTime());
criteria.setEndTime(request.getEndTime());
criteria.setExcludeQuery(StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileRequestConverter.java
deleted file mode 100644
index 62c2fbe..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileRequestConverter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.LogFileRequest;
-import org.apache.ambari.logsearch.query.model.LogFileSearchCriteria;
-import org.springframework.core.convert.converter.Converter;
-import org.springframework.stereotype.Component;
-
-@Component
-public class LogFileRequestConverter implements Converter<LogFileRequest, LogFileSearchCriteria> {
-
- @Override
- public LogFileSearchCriteria convert(LogFileRequest request) {
- LogFileSearchCriteria criteria = new LogFileSearchCriteria();
- criteria.setLogFileComponent(request.getComponent());
- criteria.setLogFileHost(request.getHost());
- criteria.setLogType(request.getLogType());
- return criteria;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileTailRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileTailRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileTailRequestConverter.java
deleted file mode 100644
index 08c6ecc..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileTailRequestConverter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.LogFileTailRequest;
-import org.apache.ambari.logsearch.query.model.LogFileTailSearchCriteria;
-import org.springframework.core.convert.converter.Converter;
-import org.springframework.stereotype.Component;
-
-@Component
-public class LogFileTailRequestConverter implements Converter<LogFileTailRequest, LogFileTailSearchCriteria> {
-
- @Override
- public LogFileTailSearchCriteria convert(LogFileTailRequest request) {
- LogFileTailSearchCriteria criteria = new LogFileTailSearchCriteria();
- criteria.setLogFileComponent(request.getComponent());
- criteria.setLogFileHost(request.getHost());
- criteria.setLogType(request.getLogType());
- criteria.setLogTailSize(request.getTailSize());
- return criteria;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
index 6c501ae..37ec7dc 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
@@ -28,8 +28,6 @@ public class ServiceGraphRequestConverter extends AbstractCommonServiceLogReques
@Override
public ServiceGraphSearchCriteria createCriteria(ServiceGraphRequest request) {
ServiceGraphSearchCriteria criteria = new ServiceGraphSearchCriteria();
- criteria.setLogFileHostName(request.getHostLogFile());
- criteria.setLogFileComponentName(request.getComponentLogFile());
criteria.setUnit(request.getUnit());
return criteria;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
index bd06546..783b0e0 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
@@ -28,8 +28,6 @@ public class ServiceLogExportRequestConverter extends AbstractCommonServiceLogRe
@Override
public ServiceLogExportSearchCriteria createCriteria(ServiceLogExportRequest request) {
ServiceLogExportSearchCriteria criteria = new ServiceLogExportSearchCriteria();
- criteria.setLogFileHostName(request.getHostLogFile());
- criteria.setLogFileComponentName(request.getComponentLogFile());
criteria.setFormat(request.getFormat());
criteria.setUtcOffset(request.getUtcOffset());
return criteria;
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogFileRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogFileRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogFileRequestConverter.java
deleted file mode 100644
index 392c9d3..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogFileRequestConverter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceLogFileRequest;
-import org.apache.ambari.logsearch.query.model.ServiceLogFileSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceLogFileRequestConverter
- extends AbstractCommonServiceLogRequestConverter<ServiceLogFileRequest, ServiceLogFileSearchCriteria> {
-
- @Override
- public ServiceLogFileSearchCriteria createCriteria(ServiceLogFileRequest request) {
- ServiceLogFileSearchCriteria criteria = new ServiceLogFileSearchCriteria();
- criteria.setLogFileHostName(request.getHostLogFile());
- criteria.setLogFileComponentName(request.getComponentLogFile());
- return criteria;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
index aa93c6a..86d055d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
@@ -29,8 +29,6 @@ public class ServiceLogRequestConverter extends AbstractCommonServiceLogRequestC
@Override
public ServiceLogSearchCriteria createCriteria(ServiceLogRequest request) {
ServiceLogSearchCriteria criteria = new ServiceLogSearchCriteria();
- criteria.setLogFileComponentName(request.getHostLogFile());
- criteria.setLogFileComponentName(request.getComponentLogFile());
criteria.setKeyword(StringEscapeUtils.unescapeXml(request.getKeyWord()));
criteria.setKeywordType(request.getKeywordType());
criteria.setSourceLogId(request.getSourceLogId());
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
index 1e58b79..2154357 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
@@ -28,8 +28,6 @@ public class ServiceLogTruncatedRequestConverter extends AbstractCommonServiceLo
@Override
public ServiceLogTruncatedSearchCriteria createCriteria(ServiceLogTruncatedRequest request) {
ServiceLogTruncatedSearchCriteria criteria = new ServiceLogTruncatedSearchCriteria();
- criteria.setLogFileHostName(request.getHostLogFile());
- criteria.setLogFileComponentName(request.getComponentLogFile());
criteria.setId(request.getId());
criteria.setScrollType(request.getScrollType());
criteria.setNumberRows(request.getNumberRows());
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java
index 4c79c69..b02c234 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java
@@ -22,14 +22,6 @@ import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
public class CommonServiceLogSearchCriteria extends CommonSearchCriteria {
- public String getTreeParams() {
- return getParam(SearchCriteriaConstants.PARAM_TREE_PARAMS, String.class);
- }
-
- public void setTreeParams(String treeParams) {
- addParam(SearchCriteriaConstants.PARAM_TREE_PARAMS, treeParams);
- }
-
public String getLevel() {
return getParam(SearchCriteriaConstants.PARAM_LEVEL, String.class);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileSearchCriteria.java
deleted file mode 100644
index e33e5eb..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileSearchCriteria.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.common.Marker;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_LOG_FILE_COMPONENT;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_LOG_FILE_HOST;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_LOG_FILE_TYPE;
-
-public class LogFileSearchCriteria extends SearchCriteria {
-
- public String getLogFileComponent() {
- return getParam(PARAM_LOG_FILE_COMPONENT, String.class);
- }
-
- public void setLogFileComponent(String logFileComponent) {
- addParam(PARAM_LOG_FILE_COMPONENT, logFileComponent);
- }
-
- public String getLogFileHost() {
- return getParam(PARAM_LOG_FILE_HOST, String.class);
- }
-
- public void setLogFileHost(String logFileHost) {
- addParam(PARAM_LOG_FILE_HOST, logFileHost);
- }
-
- public String getLogType() {
- return getParam(PARAM_LOG_FILE_TYPE, String.class);
- }
-
- public void setLogType(String logType) {
- addParam(PARAM_LOG_FILE_TYPE, logType);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileTailSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileTailSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileTailSearchCriteria.java
deleted file mode 100644
index ccea4ab..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileTailSearchCriteria.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_LOG_TAIL_SIZE;
-
-public class LogFileTailSearchCriteria extends LogFileSearchCriteria {
-
- public String getLogTailSize() {
- return getParam(PARAM_LOG_TAIL_SIZE, String.class);
- }
-
- public void setLogTailSize(String logTailSize) {
- addParam(PARAM_LOG_TAIL_SIZE, logTailSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java
index 661337f..8e397ac 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java
@@ -123,4 +123,13 @@ public class SearchCriteria {
this.globalEndTime = globalEndTime;
}
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ for (Map.Entry<String, Object> entry : paramList.entrySet()) {
+ sb.append(entry.getKey() + " : " + entry.getValue() + ";");
+ }
+ return sb.toString();
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
index cd852b5..0f4bb5a 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
@@ -25,7 +25,7 @@ import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_UN
import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_X_AXIS;
import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_Y_AXIS;
-public class ServiceAnyGraphSearchCriteria extends ServiceLogFileSearchCriteria {
+public class ServiceAnyGraphSearchCriteria extends ServiceLogSearchCriteria {
public String getxAxis() {
return getParam(PARAM_X_AXIS, String.class);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
index 8988af1..4173bac 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
@@ -20,7 +20,7 @@ package org.apache.ambari.logsearch.query.model;
import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-public class ServiceGraphSearchCriteria extends ServiceLogFileSearchCriteria {
+public class ServiceGraphSearchCriteria extends ServiceLogSearchCriteria {
public String getUnit() {
return getParam(SearchCriteriaConstants.PARAM_UNIT, String.class);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
index c7b7a39..6c757af 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
@@ -20,7 +20,7 @@ package org.apache.ambari.logsearch.query.model;
import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-public class ServiceLogExportSearchCriteria extends ServiceLogFileSearchCriteria {
+public class ServiceLogExportSearchCriteria extends ServiceLogSearchCriteria {
public void setFormat(String format) {
addParam(SearchCriteriaConstants.PARAM_FORMAT, format);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java
deleted file mode 100644
index a80a3ce..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.query.model;
-
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-
-public class ServiceLogFileSearchCriteria extends CommonServiceLogSearchCriteria {
-
- public void setLogFileHostName(String logFileHostName) {
- addParam(SearchCriteriaConstants.PARAM_HOST_LOG_FILE, logFileHostName);
- }
-
- public String getLogFileHostName() {
- return getParam(SearchCriteriaConstants.PARAM_HOST_LOG_FILE, String.class);
- }
-
- public void setLogFileComponentName(String logFileComponentName) {
- addParam(SearchCriteriaConstants.PARAM_COMPONENT_LOG_FILE, logFileComponentName);
- }
-
- public String getLogFileComponentName() {
- return getParam(SearchCriteriaConstants.PARAM_COMPONENT_LOG_FILE, String.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
index b3a6bf7..e469367 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
@@ -20,7 +20,7 @@ package org.apache.ambari.logsearch.query.model;
import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-public class ServiceLogSearchCriteria extends ServiceLogFileSearchCriteria {
+public class ServiceLogSearchCriteria extends CommonServiceLogSearchCriteria {
public void setKeyword(String keyword) {
addParam(SearchCriteriaConstants.PARAM_KEYWORD, keyword);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
index bcdac5b..277aeb9 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
@@ -20,7 +20,7 @@ package org.apache.ambari.logsearch.query.model;
import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-public class ServiceLogTruncatedSearchCriteria extends ServiceLogFileSearchCriteria {
+public class ServiceLogTruncatedSearchCriteria extends ServiceLogSearchCriteria {
public String getId() {
return getParam(SearchCriteriaConstants.PARAM_ID, String.class);
[3/6] ambari git commit: AMBARI-18310. Refactor logsearch portal code
- part 3 (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
index ff185f8..0bd326e 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
@@ -45,7 +45,6 @@ import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria;
import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria;
import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
import org.apache.ambari.logsearch.manager.AuditLogsManager;
import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria;
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java
deleted file mode 100644
index c23f457..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.rest;
-
-import javax.inject.Inject;
-import javax.ws.rs.BeanParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.apache.ambari.logsearch.model.request.impl.LogFileRequest;
-import org.apache.ambari.logsearch.model.request.impl.LogFileTailRequest;
-import org.apache.ambari.logsearch.model.response.LogFileDataListResponse;
-import org.apache.ambari.logsearch.model.response.LogListResponse;
-import org.apache.ambari.logsearch.query.model.LogFileSearchCriteria;
-import org.apache.ambari.logsearch.query.model.LogFileTailSearchCriteria;
-import org.apache.ambari.logsearch.manager.LogFileManager;
-import org.springframework.context.annotation.Scope;
-import org.springframework.core.convert.ConversionService;
-import org.springframework.stereotype.Component;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.LogFileOperationDescriptions.*;
-
-@Api(value = "logfile", description = "Logfile operations")
-@Path("logfile")
-@Component
-@Scope("request")
-public class LogFileResource {
-
- @Inject
- private LogFileManager logFileManager;
-
- @Inject
- private ConversionService conversionService;
-
- @GET
- @Produces({"application/json"})
- @ApiOperation(SEARCH_LOG_FILES_OD)
- public LogFileDataListResponse searchLogFiles(@BeanParam LogFileRequest request) {
- return logFileManager.searchLogFiles(conversionService.convert(request, LogFileSearchCriteria.class));
- }
-
- @GET
- @Path("/tail")
- @Produces({"application/json"})
- @ApiOperation(GET_LOG_FILE_TAIL_OD)
- public LogListResponse getLogFileTail(@BeanParam LogFileTailRequest request) {
- return logFileManager.getLogFileTail(conversionService.convert(request, LogFileTailSearchCriteria.class));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
index 6cc69d4..5a17147 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
@@ -34,7 +34,6 @@ import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest;
import org.apache.ambari.logsearch.model.request.impl.ServiceExtremeDatesRequest;
import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest;
-import org.apache.ambari.logsearch.model.request.impl.ServiceLogFileRequest;
import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest;
import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
@@ -44,15 +43,12 @@ import org.apache.ambari.logsearch.model.response.GroupListResponse;
import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
import org.apache.ambari.logsearch.model.response.NodeListResponse;
import org.apache.ambari.logsearch.model.response.ServiceLogResponse;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
import org.apache.ambari.logsearch.manager.ServiceLogsManager;
import org.apache.ambari.logsearch.query.model.ServiceAnyGraphSearchCriteria;
import org.apache.ambari.logsearch.query.model.ServiceExtremeDatesCriteria;
import org.apache.ambari.logsearch.query.model.ServiceGraphSearchCriteria;
import org.apache.ambari.logsearch.query.model.ServiceLogExportSearchCriteria;
-import org.apache.ambari.logsearch.query.model.ServiceLogFileSearchCriteria;
import org.apache.ambari.logsearch.query.model.ServiceLogSearchCriteria;
import org.apache.ambari.logsearch.query.model.ServiceLogTruncatedSearchCriteria;
import org.springframework.context.annotation.Scope;
@@ -132,8 +128,8 @@ public class ServiceLogsResource {
@Path("/tree")
@Produces({"application/json"})
@ApiOperation(GET_TREE_EXTENSION_OD)
- public NodeListResponse getTreeExtension(@QueryParam("hostName") @ApiParam String hostName, @BeanParam ServiceLogFileRequest request) {
- ServiceLogFileSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogFileSearchCriteria.class);
+ public NodeListResponse getTreeExtension(@QueryParam("hostName") @ApiParam String hostName, @BeanParam ServiceLogRequest request) {
+ ServiceLogSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogSearchCriteria.class);
searchCriteria.addParam("hostName", hostName); // TODO: use host_name instead - needs UI change
return serviceLogsManager.getTreeExtension(searchCriteria);
}
@@ -142,8 +138,8 @@ public class ServiceLogsResource {
@Path("/levels/counts/namevalues")
@Produces({"application/json"})
@ApiOperation(GET_LOG_LEVELS_COUNT_OD)
- public NameValueDataListResponse getLogsLevelCount(@BeanParam ServiceLogFileRequest request) {
- return serviceLogsManager.getLogsLevelCount(conversionService.convert(request, ServiceLogFileSearchCriteria.class));
+ public NameValueDataListResponse getLogsLevelCount(@BeanParam ServiceLogRequest request) {
+ return serviceLogsManager.getLogsLevelCount(conversionService.convert(request, ServiceLogSearchCriteria.class));
}
@GET
@@ -175,8 +171,8 @@ public class ServiceLogsResource {
@Path("/hosts/components")
@Produces({"application/json"})
@ApiOperation(GET_HOST_LIST_BY_COMPONENT_OD)
- public NodeListResponse getHostListByComponent(@BeanParam ServiceLogFileRequest request, @QueryParam("componentName") @ApiParam String componentName) {
- ServiceLogFileSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogFileSearchCriteria.class);
+ public NodeListResponse getHostListByComponent(@BeanParam ServiceLogRequest request, @QueryParam("componentName") @ApiParam String componentName) {
+ ServiceLogSearchCriteria searchCriteria = conversionService.convert(request, ServiceLogSearchCriteria.class);
searchCriteria.addParam("componentName", componentName); // TODO: use component_name instead - needs UI change
return serviceLogsManager.getHostListByComponent(searchCriteria);
}
@@ -185,8 +181,8 @@ public class ServiceLogsResource {
@Path("/components/levels/counts")
@Produces({"application/json"})
@ApiOperation(GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD)
- public NodeListResponse getComponentListWithLevelCounts(@BeanParam ServiceLogFileRequest request) {
- return serviceLogsManager.getComponentListWithLevelCounts(conversionService.convert(request, ServiceLogFileSearchCriteria.class));
+ public NodeListResponse getComponentListWithLevelCounts(@BeanParam ServiceLogRequest request) {
+ return serviceLogsManager.getComponentListWithLevelCounts(conversionService.convert(request, ServiceLogSearchCriteria.class));
}
@GET
@@ -198,14 +194,6 @@ public class ServiceLogsResource {
}
@GET
- @Path("/fields")
- @Produces({"application/json"})
- @ApiOperation(GET_SERVICE_LOGS_FIELD_NAME_OD)
- public String getServiceLogsFieldsName() {
- return serviceLogsManager.getServiceLogsFieldsName();
- }
-
- @GET
@Path("/schema/fields")
@Produces({"application/json"})
@ApiOperation(GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD)
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
index d398bdc..a89b5dd 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
@@ -25,7 +25,7 @@ import javax.inject.Inject;
import org.apache.ambari.logsearch.common.ExternalServerClient;
import org.apache.ambari.logsearch.common.PropertiesHelper;
-import org.apache.ambari.logsearch.conf.AuthConfig;
+import org.apache.ambari.logsearch.conf.AuthPropsConfig;
import org.apache.ambari.logsearch.util.JSONUtil;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
@@ -99,7 +99,7 @@ public class LogsearchExternalServerAuthenticationProvider extends
private ExternalServerClient externalServerClient;
@Inject
- private AuthConfig authConfig;
+ private AuthPropsConfig authPropsConfig;
/**
* Authenticating user from external-server using REST call
@@ -113,7 +113,7 @@ public class LogsearchExternalServerAuthenticationProvider extends
@Override
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
- if (!authConfig.isAuthExternalEnabled()) {
+ if (!authPropsConfig.isAuthExternalEnabled()) {
LOG.debug("external server auth is disabled.");
return authentication;
}
@@ -129,7 +129,7 @@ public class LogsearchExternalServerAuthenticationProvider extends
password = StringEscapeUtils.unescapeHtml(password);
username = StringEscapeUtils.unescapeHtml(username);
try {
- String finalLoginUrl = authConfig.getExternalAuthLoginUrl().replace("$USERNAME", username);
+ String finalLoginUrl = authPropsConfig.getExternalAuthLoginUrl().replace("$USERNAME", username);
String responseObj = (String) externalServerClient.sendGETRequest(
finalLoginUrl, String.class, null, username, password);
if (!isAllowedRole(responseObj)) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
index 9662266..dc70b82 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
@@ -20,7 +20,7 @@ package org.apache.ambari.logsearch.web.security;
import java.util.Collection;
-import org.apache.ambari.logsearch.conf.AuthConfig;
+import org.apache.ambari.logsearch.conf.AuthPropsConfig;
import org.apache.ambari.logsearch.util.CommonUtil;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
@@ -42,14 +42,14 @@ public class LogsearchFileAuthenticationProvider extends LogsearchAbstractAuthen
private static Logger logger = Logger.getLogger(LogsearchFileAuthenticationProvider.class);
@Inject
- private AuthConfig authConfig;
+ private AuthPropsConfig authPropsConfig;
@Inject
private UserDetailsService userDetailsService;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
- if (!authConfig.isAuthFileEnabled()) {
+ if (!authPropsConfig.isAuthFileEnabled()) {
logger.debug("File auth is disabled.");
return authentication;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java
index f6c7df0..52dd66e 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchLdapAuthenticationProvider.java
@@ -20,7 +20,7 @@ package org.apache.ambari.logsearch.web.security;
import java.util.List;
-import org.apache.ambari.logsearch.conf.AuthConfig;
+import org.apache.ambari.logsearch.conf.AuthPropsConfig;
import org.apache.log4j.Logger;
import org.springframework.ldap.CommunicationException;
import org.springframework.ldap.core.support.LdapContextSource;
@@ -47,7 +47,7 @@ public class LogsearchLdapAuthenticationProvider extends
private String logStatement = "";
@Inject
- private AuthConfig authConfig;
+ private AuthPropsConfig authPropsConfig;
public LogsearchLdapAuthenticationProvider() {
}
@@ -55,7 +55,7 @@ public class LogsearchLdapAuthenticationProvider extends
@PostConstruct
public void postConstruct() {
logger.debug("Creating object of ldap auth provider ");
- if (authConfig.isAuthLdapEnabled()) {
+ if (authPropsConfig.isAuthLdapEnabled()) {
ldapAuthProvider = loadLdapAuthenticationProvider();
} else {
logger.info("Ldap auth is disabled");
@@ -65,7 +65,7 @@ public class LogsearchLdapAuthenticationProvider extends
@Override
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
- if (!authConfig.isAuthLdapEnabled()) {
+ if (!authPropsConfig.isAuthLdapEnabled()) {
logger.debug("Ldap auth is disabled");
return authentication;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
index 5dc1c1f..17d099b 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
@@ -18,7 +18,7 @@
*/
package org.apache.ambari.logsearch.web.security;
-import org.apache.ambari.logsearch.conf.AuthConfig;
+import org.apache.ambari.logsearch.conf.AuthPropsConfig;
import org.apache.ambari.logsearch.web.model.User;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
@@ -37,11 +37,11 @@ public class LogsearchSimpleAuthenticationProvider extends LogsearchAbstractAuth
private static Logger logger = Logger.getLogger(LogsearchSimpleAuthenticationProvider.class);
@Inject
- private AuthConfig authConfig;
+ private AuthPropsConfig authPropsConfig;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
- if (!authConfig.isAuthSimpleEnabled()) {
+ if (!authPropsConfig.isAuthSimpleEnabled()) {
logger.debug("Simple auth is disabled");
return authentication;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties
index d89a6c9..9a44761 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/default.properties
@@ -13,28 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#Service Logs Field Names
-logsearch.service.logs.fields=logtime,level,event_count,ip,type,path,file,line_number,host,log_message,method,id
-#Exclude Column List for Service Logs
-logsearch.solr.service.logs.exclude.columnlist=tags,text,message,seq_num
-
-#Exclude Column List for Ranger Audits
-logsearch.solr.audit.logs.exclude.columnlist=tags,tags_str,seq_num
-
-#Value Mapping for Audit Fields
-#Example FieldName=ValueOfUI:ValueOfSolr
-result=Allowed:1,Denied:0
-
-#Column Mapping
-#Example CoulumnInSolr:ColumnInUI
-#For Service Logs
-logsearch.solr.service.logs.column.mapping=bundle_id:Bundle Id,thread_name:Thread,log_message:Message,case_id:Case Id,cluster:Cluster,event_count:Event Count,file:File,host:Host,id:Id,ip:Ip,level:Level,line_number:Line Number,logfile_line_number:Logfile Line Number,logger_name:Logger Name,logtype:Log Type,method:Method,path:Path,rowtype:Row Type,type:Type
-
-#For Audit Logs
-logsearch.solr.audit.logs.column.mapping=access:Access Type,reqUser:User,enforcer:Access Enforcer,ip:IP,action:Action,agent:Agent,agentHost:Agent Host,authType:Auth Type,bundle_id:Bundle Id,case_id:Case Id,cliIP:Client Ip,cliType:Client Type,cluster:Cluster,dst:DST,event_count:Event Count,file:File,host:Host,id:Id,level:Level,log_message:Log Message,logfile_line_number:Logfile Line Number,logger_name:Logger Name,logType:Log Type,path:Path,perm:Perm,policy:Policy,proxyAuthType:Proxy Auth Type,proxyUsers:Proxy Users,reason:Reason,repo:Repo,repoType:Repo Type,req_caller_id:Req Caller Id,req_self_id:Req Self Id,reqContext:Req Context,reqData:Req Data,resource:Resource,resType:Res Type,result:Result,seq_num:Seq Num,sess:Sess,text:Text,type:Type,ugi:UGI
-
-#login method
#Note: Simple will be supported only if both file and ldap is disabled.
logsearch.auth.file.enable=true
logsearch.auth.ldap.enable=false
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js
index 24cbd5a..664f55f 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js
@@ -18,15 +18,13 @@
define(['backbone','utils/LangSupport', 'backbone.marionette'],function(Backbone,localization) {
'use strict';
-
- //var SessionMgr = require('mgrs/SessionMgr');
+
/*
* Localization initialization
*/
localization.setDefaultCulture(); // will take default that is en
var App = new Backbone.Marionette.Application();
- //App.userProfile = SessionMgr.getUserProfile();
/* Add application regions here */
App.addRegions({
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js
index 0f72697..53ec922 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VAuditLogListBase.js
@@ -58,7 +58,7 @@ define(['require',
}, options);
return this.constructor.nonCrudOperation.call(this, url, 'GET', options);
- },
+ }
},{
/**
* Table Cols to be passed to Backgrid
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js
index 72ab530..08a8271 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collection_bases/VLogListBase.js
@@ -76,19 +76,18 @@ define(['require',
contentType : 'application/json',
dataType : 'json'
}, options);
-
return this.constructor.nonCrudOperation.call(this, url, 'GET', options);
},
- getServiceLogSchemaFields : function(token, options){
- var url = Globals.baseURL + 'service/logs/schema/fields';
-
- options = _.extend({
- data : $.param(token),
- contentType : 'application/json',
- dataType : 'json'
- }, options);
+ getServiceLogSchemaFields : function(token, options){
+ var url = Globals.baseURL + 'service/logs/schema/fields';
- return this.constructor.nonCrudOperation.call(this, url, 'GET', options);
+ options = _.extend({
+ data: $.param(token),
+ contentType: 'application/json',
+ dataType: 'json'
+ }, options);
+
+ return this.constructor.nonCrudOperation.call(this, url, 'GET', options);
},
getTruncatedLogs : function(token, options){
var url = Globals.baseURL + 'service/logs/truncated';
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js
index ac82708..c175397 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/BaseCollection.js
@@ -152,7 +152,6 @@ define(['require',
var retCols = _.map(cols, function(v, k, l){
var defaults = collection.constructor.tableCols[k];
if(! defaults){
- //console.log("Error!! " + k + " not found in collection: " , collection);
defaults = {};
}
return _.extend({ 'name' : k }, defaults, v );
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/SchemaFieldList.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/SchemaFieldList.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/SchemaFieldList.js
new file mode 100644
index 0000000..a1c2799
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/collections/SchemaFieldList.js
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+define(['require', 'backbone'], function(require, Backbone) {
+ 'use strict';
+
+ var SchemaField = Backbone.Model.extend({
+ });
+
+ return Backbone.Collection.extend({
+ model: SchemaField,
+ url: '../static/schema_fields.json'
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/mgrs/SessionMgr.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/mgrs/SessionMgr.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/mgrs/SessionMgr.js
deleted file mode 100644
index 0809ce0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/mgrs/SessionMgr.js
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-// Manages the user session
-define(function(require){
- 'use strict';
-
- // var VXPortalUser = require('models/VXPortalUser');
-
- // // Private properties
- // var vXPortalUser = null;
- // var vSessionSettings = null;
-
- // // Public methods
- // var SessionMgr = {};
-
- // /**
- // * Gets the user profile for the given session
- // *
- // * @returns VXPortalUser
- // */
-
- // SessionMgr.getUserProfile = function() {
- // if ( vXPortalUser){
- // return vXPortalUser;
- // }
-
- // vXPortalUser = new VXPortalUser();
- // vXPortalUser.getUserProfile({async : false,cache:false}).done(function(data){
- // vXPortalUser.set(data);
- // });
- // return vXPortalUser;
- // };
-
-
- // SessionMgr.getLoginId = function() {
- // if (vXPortalUser) {
- // return vXPortalUser.get('loginId');
- // }
- // };
-
- // SessionMgr.userInRole = function(role) {
- // var vXPortalUser = SessionMgr.getUserProfile();
- // var userRoles = vXPortalUser.get('userRoleList');
- // if (!userRoles || !role) {
- // return false;
- // }
- // if (userRoles.constructor != Array) {
- // userRoles = [ userRoles ];
- // }
-
- // return (userRoles.indexOf(role) > -1);
- // };
-
- // SessionMgr.getUserRoles = function() {
- // var vXPortalUser = SessionMgr.getUserProfile();
- // var userRoles = vXPortalUser.get('userRoleList');
- // if (!userRoles) {
- // return [];
- // }
- // if (userRoles.constructor != Array) {
- // userRoles = [ userRoles ];
- // }
-
- // return userRoles;
- // };
-
- // SessionMgr.getSetting = function(key) {
- // if (!vSessionSettings) {
- // var msResponse = GeneralMgr.getSessionSettings();
- // if (msResponse.isSuccess()) {
- // vSessionSettings = msResponse.response;
- // }
- // }
- // var value = null;
- // if (vSessionSettings && key) {
- // vSessionSettings.each(function(vNameValue) {
- // if (vNameValue.get('name') == key) {
- // value = vNameValue.get('value');
- // }
- // });
- // }
- // return value;
- // };
-
- // SessionMgr.resetSession = function() {
- // vXPortalUser = null;
- // vSessionSettings = null;
- // MSCacheMgr.resetAll();
- // };
-
- // /**
- // * Logs out the user and resets all session variables
- // */
- // SessionMgr.logout = function(reDirectUser) {
- // SessionMgr.resetSession();
- // MSCacheMgr.resetAll();
- // if (reDirectUser) {
- // // This will ask the browser to redirect
- // window.location.replace("logout.html");
- // } else {
- // // We will do an implicit logout
- // $.ajax({
- // url : 'logout.html',
- // type : 'GET',
- // async : false
- // });
- // }
- // };
-
- // SessionMgr.isSystemAdmin = function(){
- // return this.userInRole('ROLE_SYS_ADMIN') ? true : false;
- // };
-
- // SessionMgr.isUser = function(){
- // var roles = this.getRoleInUserSchool();
- // return $.inArray('ROLE_USER',roles) != -1 ? true : false ;
- // };
- // return SessionMgr;
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js
index b6e8d7d..8356b9c 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js
@@ -1,85 +1,91 @@
/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-define(['require','App'], function(require, App){
- 'use strict';
-
- var Globals = {};
-
- Globals.settings = {};
- Globals.settings.PAGE_SIZE = 25;
- Globals.settings.uploadDefaultOpts = {
- disableImageResize: false,
- maxFileSize: 5000000,
- autoUpload : false
- //maxNumberOfFiles : 2
- };
- Globals.settings.MAX_VALUE = 2147483647;
+define(['require', 'collections/SchemaFieldList'], function (require, SchemaFieldList) {
+ 'use strict';
- Globals.keys = {};
- Globals.keys.ENTER_KEY = 13;
- Globals.keys.ESC_KEY = 27;
-
- Globals.EventHistory = {
- totalCount : 50
- };
+ var Globals = {};
- Globals.baseURL = '../api/v1/';
- //Globals.baseURL = App.baseUrl;
+ Globals.settings = {};
+ Globals.settings.PAGE_SIZE = 25;
+ Globals.settings.uploadDefaultOpts = {
+ disableImageResize: false,
+ maxFileSize: 5000000,
+ autoUpload: false
+ };
+ Globals.settings.MAX_VALUE = 2147483647;
- Globals.AppTabs = {
- DASHBOARD : { value:1, valStr: 'Dashboard'},
- MAINVIEW : { value:2, valStr: 'Main View'}
- };
+ Globals.keys = {};
+ Globals.keys.ENTER_KEY = 13;
+ Globals.keys.ESC_KEY = 27;
- Globals.BooleanValue = {
- BOOL_TRUE:{value:"true", label:'True'},
- BOOL_FALSE:{value:"false", label:'False'}
- };
- Globals.paramsNameMapping = {
- q:{label:'Query'},
- from:{label:'From'},
- to:{label:'To'},
- unit:{label:'Unit'},
- level:{label:'Level'},
- mustNot:{label:'Exclude Component'},
- mustBe:{label:'Include Component'},
- iMessage:{label:'Include Message'},
- eMessage:{label:'Exclude Message'},
- time:{label:''},
- includeQuery : {label:"Include Column"},
- excludeQuery : {label:"Exclude Column"},
- dateRangeLabel : {label : "Date Range"}
- };
+ Globals.EventHistory = {
+ totalCount: 50
+ };
- Globals.graphType = {
- MULTILINE:{value:1},
- HISTOGRAM:{value:2},
- PIE:{value:3},
- TABLE:{value:4}
- };
+ Globals.baseURL = '../api/v1/';
- Globals.dateFormat = "YYYY-MM-DD HH:mm:ss.SSS";
- Globals.splitToken = "|i::e|";
- Globals.eventName = {
- serviceLogsIncludeColumns : "search:serviceLogs:include",
- serviceLogsExcludeColumns : "search:serviceLogs:exclude"
- };
- Globals.serviceLogsColumns = [];
- return Globals;
+ Globals.AppTabs = {
+ DASHBOARD: {value: 1, valStr: 'Dashboard'},
+ MAINVIEW: {value: 2, valStr: 'Main View'}
+ };
+
+ Globals.BooleanValue = {
+ BOOL_TRUE: {value: "true", label: 'True'},
+ BOOL_FALSE: {value: "false", label: 'False'}
+ };
+ Globals.paramsNameMapping = {
+ q: {label: 'Query'},
+ from: {label: 'From'},
+ to: {label: 'To'},
+ unit: {label: 'Unit'},
+ level: {label: 'Level'},
+ mustNot: {label: 'Exclude Component'},
+ mustBe: {label: 'Include Component'},
+ iMessage: {label: 'Include Message'},
+ eMessage: {label: 'Exclude Message'},
+ time: {label: ''},
+ includeQuery: {label: "Include Column"},
+ excludeQuery: {label: "Exclude Column"},
+ dateRangeLabel: {label: "Date Range"}
+ };
+
+ Globals.graphType = {
+ MULTILINE: {value: 1},
+ HISTOGRAM: {value: 2},
+ PIE: {value: 3},
+ TABLE: {value: 4}
+ };
+
+ Globals.dateFormat = "YYYY-MM-DD HH:mm:ss.SSS";
+ Globals.splitToken = "|i::e|";
+ Globals.eventName = {
+ serviceLogsIncludeColumns: "search:serviceLogs:include",
+ serviceLogsExcludeColumns: "search:serviceLogs:exclude"
+ };
+ Globals.serviceLogsColumns = [];
+ Globals.schemaFields = new SchemaFieldList().fetch({async: false}).responseJSON;
+ Globals.defaultServiceLogMappings = Globals.schemaFields.serviceLogMappings;
+ Globals.defaultServiceLogExcludes = Globals.schemaFields.serviceLogExcludes;
+ Globals.defaultAuditLogMappings = Globals.schemaFields.auditLogMappings;
+ Globals.defaultAuditLogExcludes = Globals.schemaFields.auditLogExcludes;
+ Globals.invertedServiceLogMappings = _.invert(Globals.defaultServiceLogMappings);
+ Globals.invertedAuditLogMappings = _.invert(Globals.defaultAuditLogMappings);
+
+ return Globals;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js
index 62d785b..4c23290 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/ViewUtils.js
@@ -18,214 +18,249 @@
*/
-
define(['require',
- 'utils/Utils',
- 'moment',
- 'collections/VNameValueList',
- 'utils/Globals'
-], function(require, Utils, moment, VNameValueList, Globals) {
- 'use strict';
-
- var ViewUtil = {};
-
- ViewUtil.setdefaultParams = function() {
- var fromSolr, toSolr,that=this;
- var params = Utils.getQueryParams(window.location.search);
- this.defaultParams = {
- q: "*:*",
- from: moment().hours("00").minutes("00").seconds("01").milliseconds("000").toJSON(),
- to: moment().hours("23").minutes("59").seconds("59").milliseconds("999").toJSON(),
- unit: "+1HOUR",
- level: "FATAL,ERROR,WARN"
- };
- var applyParamsDate = function(date) {
- if (date) {
- var dateString = date.split(',');
- if (dateString.length) {
- var checkDate = Utils.dateUtil.getMomentUTC(dateString[0]);
- if (checkDate.isValid()) {
- if (dateString[1]) {
- checkDate.millisecond(dateString[1])
- } else {
- checkDate.millisecond('000')
- }
- return checkDate.toJSON();
- }
- }
+ 'utils/Utils',
+ 'moment',
+ 'collections/VNameValueList',
+ 'utils/Globals'
+], function (require, Utils, moment, VNameValueList, Globals) {
+ 'use strict';
+
+ var ViewUtil = {};
+
+ ViewUtil.setdefaultParams = function () {
+ var fromSolr, toSolr, that = this;
+ var params = Utils.getQueryParams(window.location.search);
+ this.defaultParams = {
+ q: "*:*",
+ from: moment().hours("00").minutes("00").seconds("01").milliseconds("000").toJSON(),
+ to: moment().hours("23").minutes("59").seconds("59").milliseconds("999").toJSON(),
+ unit: "+1HOUR",
+ level: "FATAL,ERROR,WARN"
+ };
+ var applyParamsDate = function (date) {
+ if (date) {
+ var dateString = date.split(',');
+ if (dateString.length) {
+ var checkDate = Utils.dateUtil.getMomentUTC(dateString[0]);
+ if (checkDate.isValid()) {
+ if (dateString[1]) {
+ checkDate.millisecond(dateString[1])
+ } else {
+ checkDate.millisecond('000')
}
+ return checkDate.toJSON();
+ }
}
- if (params.bundle_id && !params.start_time && !params.end_time) {
- var collection = new VNameValueList();
-
- collection.url = Globals.baseURL + "service/logs/solr/boundarydates";
- collection.modelAttrName = "vNameValues";
- _.extend(collection.queryParams, {
- "bundle_id": params.bundle_id
- });
- collection.fetch({
- reset: true,
- async: false,
- success: function(data) {
- collection.each(function(model) {
- if (model.get('name') == "From") {
- fromSolr = moment(parseInt(model.get('value'))).toJSON();
- }
- if (model.get('name') == "To") {
- toSolr = moment(parseInt(model.get('value'))).toJSON();
- }
- if(fromSolr && toSolr){
- that.defaultParams['dateRangeLabel'] = "Custom Range";
- }
- })
-
- }
- });
- }
- if (params.bundle_id) {
- this.defaultParams['bundle_id'] = params.bundle_id;
- }
- if (params.start_time) {
- var startDateString = applyParamsDate(params.start_time);
- }
- if (params.end_time) {
- var endDateString = applyParamsDate(params.end_time);
- }
- if (params.host_name) {
- this.defaultParams['host_name'] = params.host_name;
- }
- if (params.component_name) {
- this.defaultParams['component_name'] = params.component_name;
- }
- if (params.file_name) {
- this.defaultParams['file_name'] = params.file_name;
- }
- if (startDateString && endDateString) {
- if (params.timezone) {
- var timeZoneObject = worldMapTime.getTimeZoneObject(params.timezone)
- if (timeZoneObject.length) {
- var timeZoneName = timeZoneObject[0].timezone
- }
- if (timeZoneName) {
- var startEncodeDate = params.start_time.replace(",", ".")
- var endEncodeDate = params.end_time.replace(",", ".")
- startDateString = moment.tz(startEncodeDate, timeZoneName).toJSON();
- endDateString = moment.tz(endEncodeDate, timeZoneName).toJSON();
- var timeZoneString = timeZoneName + "," + timeZoneObject[0].zoneName + "," + timeZoneObject.length;
- Utils.localStorage.setLocalStorage('timezone', timeZoneString);
- moment.tz.setDefault(timeZoneName);
- }
+ }
+ }
+ if (params.bundle_id && !params.start_time && !params.end_time) {
+ var collection = new VNameValueList();
+
+ collection.url = Globals.baseURL + "service/logs/solr/boundarydates";
+ collection.modelAttrName = "vNameValues";
+ _.extend(collection.queryParams, {
+ "bundle_id": params.bundle_id
+ });
+ collection.fetch({
+ reset: true,
+ async: false,
+ success: function (data) {
+ collection.each(function (model) {
+ if (model.get('name') == "From") {
+ fromSolr = moment(parseInt(model.get('value'))).toJSON();
}
- this.defaultParams['end_time'] = endDateString
- this.defaultParams['start_time'] = startDateString;
- this.defaultParams['from'] = startDateString;
- this.defaultParams['to'] = endDateString;
- this.defaultParams['dateRangeLabel'] = "Custom Range";
- }
- if (fromSolr && toSolr) {
- this.defaultParams['from'] = fromSolr;
- this.defaultParams['to'] = toSolr;
- this.defaultParams['dateRangeLabel'] = "Custom Range";
+ if (model.get('name') == "To") {
+ toSolr = moment(parseInt(model.get('value'))).toJSON();
+ }
+ if (fromSolr && toSolr) {
+ that.defaultParams['dateRangeLabel'] = "Custom Range";
+ }
+ })
+
}
+ });
}
- ViewUtil.getDefaultParams = function() {
- return $.extend(true, {}, this.defaultParams);
+ if (params.bundle_id) {
+ this.defaultParams['bundle_id'] = params.bundle_id;
}
- ViewUtil.getCountDistributionHTML = function(node) {
- if (!node.logLevelCount)
- return "";
- return '<div data-node = "' + node.name + '" class="nodebar">' + ViewUtil.getLevelDistributionHTML(node) + '</div>';
- };
- ViewUtil.getLevelDistributionHTML = function(node) {
- var html = "";
- if (!_.isUndefined(node.logLevelCount) && !_.isArray(node.logLevelCount))
- node.logLevelCount = [node.logLevelCount];
- var toPct = ViewUtil.calculatePercentge(node.logLevelCount);
- _.each(node.logLevelCount, function(data) {
- //html += '<div class="node '+data.name+'" style="width:'+toPct(data)+'%;" data-toggle="tooltip" title="'+data.value+'" data-original-title="'+data.value+'"></div>';
- html += '<div class="node ' + data.name + '" style="width:' + toPct(data) + '%;"></div>';
- });
- return html;
- };
- ViewUtil.calculatePercentge = function(values) {
- var sum = 0;
- for (var i = 0; i != values.length; ++i) {
- sum = sum + parseInt(values[i].value, 10);
+ if (params.start_time) {
+ var startDateString = applyParamsDate(params.start_time);
+ }
+ if (params.end_time) {
+ var endDateString = applyParamsDate(params.end_time);
+ }
+ if (params.host_name) {
+ this.defaultParams['host_name'] = params.host_name;
+ }
+ if (params.component_name) {
+ this.defaultParams['component_name'] = params.component_name;
+ }
+ if (params.file_name) {
+ this.defaultParams['file_name'] = params.file_name;
+ }
+ if (startDateString && endDateString) {
+ if (params.timezone) {
+ var timeZoneObject = worldMapTime.getTimeZoneObject(params.timezone)
+ if (timeZoneObject.length) {
+ var timeZoneName = timeZoneObject[0].timezone
}
- var scale = 100 / sum;
- return function(x) {
- return (parseInt(x.value, 10) * scale) /*.toFixed(5)*/ ;
- };
+ if (timeZoneName) {
+ var startEncodeDate = params.start_time.replace(",", ".")
+ var endEncodeDate = params.end_time.replace(",", ".")
+ startDateString = moment.tz(startEncodeDate, timeZoneName).toJSON();
+ endDateString = moment.tz(endEncodeDate, timeZoneName).toJSON();
+ var timeZoneString = timeZoneName + "," + timeZoneObject[0].zoneName + "," + timeZoneObject.length;
+ Utils.localStorage.setLocalStorage('timezone', timeZoneString);
+ moment.tz.setDefault(timeZoneName);
+ }
+ }
+ this.defaultParams['end_time'] = endDateString
+ this.defaultParams['start_time'] = startDateString;
+ this.defaultParams['from'] = startDateString;
+ this.defaultParams['to'] = endDateString;
+ this.defaultParams['dateRangeLabel'] = "Custom Range";
+ }
+ if (fromSolr && toSolr) {
+ this.defaultParams['from'] = fromSolr;
+ this.defaultParams['to'] = toSolr;
+ this.defaultParams['dateRangeLabel'] = "Custom Range";
+ }
+ }
+ ViewUtil.getDefaultParams = function () {
+ return $.extend(true, {}, this.defaultParams);
+ }
+ ViewUtil.getCountDistributionHTML = function (node) {
+ if (!node.logLevelCount)
+ return "";
+ return '<div data-node = "' + node.name + '" class="nodebar">' + ViewUtil.getLevelDistributionHTML(node) + '</div>';
+ };
+ ViewUtil.getLevelDistributionHTML = function (node) {
+ var html = "";
+ if (!_.isUndefined(node.logLevelCount) && !_.isArray(node.logLevelCount))
+ node.logLevelCount = [node.logLevelCount];
+ var toPct = ViewUtil.calculatePercentge(node.logLevelCount);
+ _.each(node.logLevelCount, function (data) {
+ //html += '<div class="node '+data.name+'" style="width:'+toPct(data)+'%;" data-toggle="tooltip" title="'+data.value+'" data-original-title="'+data.value+'"></div>';
+ html += '<div class="node ' + data.name + '" style="width:' + toPct(data) + '%;"></div>';
+ });
+ return html;
+ };
+ ViewUtil.calculatePercentge = function (values) {
+ var sum = 0;
+ for (var i = 0; i != values.length; ++i) {
+ sum = sum + parseInt(values[i].value, 10);
+ }
+ var scale = 100 / sum;
+ return function (x) {
+ return (parseInt(x.value, 10) * scale) /*.toFixed(5)*/;
};
+ };
- ViewUtil.getDefaultParamsForHierarchy = function() {
- return ViewUtil.getDefaultParams();
- };
+ ViewUtil.getDefaultParamsForHierarchy = function () {
+ return ViewUtil.getDefaultParams();
+ };
- ViewUtil.setLatestTimeParams = function(params) {
- if (params && params.dateRangeLabel) {
- var arr = Utils.dateUtil.getRelativeDateFromString(params.dateRangeLabel);
- if (_.isArray(arr)) {
- params.from = arr[0].toJSON();
- params.to = arr[1].toJSON();
- };
- }
+ ViewUtil.setLatestTimeParams = function (params) {
+ if (params && params.dateRangeLabel) {
+ var arr = Utils.dateUtil.getRelativeDateFromString(params.dateRangeLabel);
+ if (_.isArray(arr)) {
+ params.from = arr[0].toJSON();
+ params.to = arr[1].toJSON();
+ }
+ ;
+ }
- };
-
- ViewUtil.foramtLogMessageAsLogFile = function(model, logMessageHtmlClass){
- var attrs = model.attributes;
- var str="";
- if(attrs.logtime)
- str += moment(attrs.logtime).format("YYYY-MM-DD HH:mm:ss,SSS")+" ";
- if(attrs.level)
- str += "<span class='"+(""+attrs.level).toUpperCase()+"'>"+(""+attrs.level).toUpperCase()+"</span> ";
- if(attrs.thread_name)
- str += $.trim(attrs.thread_name)+" ";
- if(attrs.logger_name)
- str += $.trim(attrs.logger_name)+" ";
- if(attrs.file && attrs.line_number)
- str += attrs.file+":"+attrs.line_number+" ";
-// if(attrs.cluster)
-// str += attrs.cluster+" ";
- if(attrs.log_message)
- str += "<span class='"+(logMessageHtmlClass ? logMessageHtmlClass : "logMessage")+"'>- "+Utils.escapeHtmlChar(attrs.log_message)+" </span>";
- return str;
+ };
+
+ ViewUtil.foramtLogMessageAsLogFile = function (model, logMessageHtmlClass) {
+ var attrs = model.attributes;
+ var str = "";
+ if (attrs.logtime)
+ str += moment(attrs.logtime).format("YYYY-MM-DD HH:mm:ss,SSS") + " ";
+ if (attrs.level)
+ str += "<span class='" + ("" + attrs.level).toUpperCase() + "'>" + ("" + attrs.level).toUpperCase() + "</span> ";
+ if (attrs.thread_name)
+ str += $.trim(attrs.thread_name) + " ";
+ if (attrs.logger_name)
+ str += $.trim(attrs.logger_name) + " ";
+ if (attrs.file && attrs.line_number)
+ str += attrs.file + ":" + attrs.line_number + " ";
+ if (attrs.log_message)
+ str += "<span class='" + (logMessageHtmlClass ? logMessageHtmlClass : "logMessage") + "'>- " + Utils.escapeHtmlChar(attrs.log_message) + " </span>";
+ return str;
+ }
+
+ ViewUtil.scrollToElement = function (top, speed) {
+ if (!top)
+ return;
+ $("html, body").animate({scrollTop: (top - 200)}, (speed) ? speed : 300);
+ };
+
+ ViewUtil.formatAuditGraphData = function (collection) {
+ var mainObj = [], len = 0, that = this;
+ collection.each(function (m, index) {
+ var userName = m.get("name");
+ if (len < userName.length)
+ len = userName.length;
+ var compo = m.get("dataCount");
+ for (var i = 0; i < compo.length; i++) {
+ var b = {label: userName, value: parseInt(compo[i].value, 10)}
+ var ret = _.findWhere(mainObj, {key: compo[i].name});
+ if (ret) {
+ ret.values.push(b);
+ } else {
+ mainObj.push({
+ key: compo[i].name,
+ values: [b],
+ color: Utils.getRandomColor(compo[i].name)
+ });
+ }
+ }
+ });
+ return {
+ max: len,
+ arr: mainObj
}
-
- ViewUtil.scrollToElement = function(top, speed){
- if(!top)
- return;
- $("html, body").animate({ scrollTop : (top -200) }, (speed) ? speed : 300);
- };
-
- ViewUtil.formatAuditGraphData = function(collection){
- var mainObj = [],len=0,that=this;
- collection.each(function(m,index){
- var userName = m.get("name");
- if(len < userName.length )
- len = userName.length;
- var compo = m.get("dataCount");
- for(var i=0;i < compo.length; i++){
- var b = {label:userName,value:parseInt(compo[i].value,10)}
- var ret = _.findWhere(mainObj,{key:compo[i].name});
- if(ret){
- ret.values.push(b);
- }else{
- mainObj.push({
- key : compo[i].name,
- values : [b],
- color : Utils.getRandomColor(compo[i].name)
- });
- }
- }
- });
- return {
- max : len,
- arr : mainObj
- }
+ };
+
+ /**
+ * Generate sorted named schema field list for service/audit logs
+ * @param data Response data
+ * @param fieldMappings Solr field - UI field mapping
+ * @param excludes Array of fields that needs to be filtered out on UI
+ * @returns sorted schema field list (human readable format)
+ */
+ ViewUtil.getLogSchemaFields = function(data, fieldMappings, excludes) {
+ var jsonData = {};
+ for (var key in data) {
+ if ($.inArray(key.toString(), excludes) == -1) {
+ if (fieldMappings.hasOwnProperty(key)) {
+ jsonData[key] = fieldMappings[key];
+ } else {
+ jsonData[key] = key;
+ }
+ }
}
+ return _.sortBy(jsonData, function(k, v){return k});
+ };
+
+
+ ViewUtil.replaceColumnNamesWithKeys = function (collection, nameKeyMap, addingAstrik) {
+ var result = [];
+ collection.each(function (m) {
+ var data = {};
+ var value = addingAstrik == true ? Utils.manipulateValueForAddingAstrik(m.get("value")) : m.get("value");
+ if (nameKeyMap[m.get("category")] === undefined) {
+ data[m.get("category")] = m.get("value");
+ } else {
+ data[nameKeyMap[m.get("category")]] = m.get("value");
+ }
+ result.push(data);
+ });
+ return result;
+ };
- return ViewUtil;
+ return ViewUtil;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js
index a399cbf..4e09e88 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditTabLayoutView.js
@@ -1,459 +1,429 @@
/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
define(['require',
- 'backbone',
- 'utils/Globals',
- 'utils/Utils',
- 'utils/ViewUtils',
- 'collections/VGroupList',
- 'collections/VAuditLogList',
- 'models/VAuditLog',
- 'hbs!tmpl/audit/AuditTabLayoutView_tmpl',
- 'moment'
-],function(require,Backbone,Globals,Utils,ViewUtils,VGroupList,VAuditLogList,VAuditLog,AuditTabLayoutViewTmpl,moment){
+ 'backbone',
+ 'utils/Globals',
+ 'utils/Utils',
+ 'utils/ViewUtils',
+ 'collections/VGroupList',
+ 'collections/VAuditLogList',
+ 'models/VAuditLog',
+ 'hbs!tmpl/audit/AuditTabLayoutView_tmpl',
+ 'moment'
+], function (require, Backbone, Globals, Utils, ViewUtils, VGroupList, VAuditLogList, VAuditLog, AuditTabLayoutViewTmpl, moment) {
- 'use strict';
+ 'use strict';
- return Backbone.Marionette.Layout.extend(
- /** @lends LogLevelView */
- {
- _viewName : 'AuditTabLayoutView',
+ return Backbone.Marionette.Layout.extend(
+ {
+ _viewName: 'AuditTabLayoutView',
- template: AuditTabLayoutViewTmpl,
+ template: AuditTabLayoutViewTmpl,
- /** Layout sub regions */
- regions: {
- RAuditTable : "[data-id='auditTable']",
- RVisualSearch : "#r_vsSearch",
- RVisualSearchInc : "#r_vsSearchInc",
- RVisualSearchEx : "#r_vsSearchEx",
- RAuditLine : "#r_AuditLine",
- RAuditAggregated : "[data-id='auditAggregated']",
- },
+ /** Layout sub regions */
+ regions: {
+ RAuditTable: "[data-id='auditTable']",
+ RVisualSearch: "#r_vsSearch",
+ RVisualSearchInc: "#r_vsSearchInc",
+ RVisualSearchEx: "#r_vsSearchEx",
+ RAuditLine: "#r_AuditLine",
+ RAuditAggregated: "[data-id='auditAggregated']",
+ },
- /** ui selector cache */
- ui: {
- viewType: "input[name='viewTypeAudit']",
- excludeComponents : "#excludeComponents",
- includeComponents : "#includeComponents",
- collapseArrowClick : "a.collapse-link.chkArrow"
- },
+ /** ui selector cache */
+ ui: {
+ viewType: "input[name='viewTypeAudit']",
+ excludeComponents: "#excludeComponents",
+ includeComponents: "#includeComponents",
+ collapseArrowClick: "a.collapse-link.chkArrow"
+ },
- /** ui events hash */
- events: function() {
- var events = {};
- events['click [data-id="refresh-tab-audit"]'] = 'onAuditTabRefresh';
- events['change ' + this.ui.viewType] = 'onViewTypeChange';
- events['click ' +this.ui.collapseArrowClick] = function(e){
- if($(e.currentTarget).find('i').hasClass('fa-chevron-down')){
- if(this.RAuditAggregated.currentView){
- this.RAuditAggregated.currentView.trigger("button:min:max");
- }
- }
- }
- return events;
- },
+ /** ui events hash */
+ events: function () {
+ var events = {};
+ events['click [data-id="refresh-tab-audit"]'] = 'onAuditTabRefresh';
+ events['change ' + this.ui.viewType] = 'onViewTypeChange';
+ events['click ' + this.ui.collapseArrowClick] = function (e) {
+ if ($(e.currentTarget).find('i').hasClass('fa-chevron-down')) {
+ if (this.RAuditAggregated.currentView) {
+ this.RAuditAggregated.currentView.trigger("button:min:max");
+ }
+ }
+ };
+ return events;
+ },
+ initialize: function (options) {
+ _.extend(this, _.pick(options, 'globalVent'));
+ this.defaultParams = ViewUtils.getDefaultParamsForHierarchy();
+ delete this.defaultParams.level;
+ this.vent = new Backbone.Wreqr.EventAggregator();
+ this.initializeCollections();
+ this.columns = [];
+ this.bindEvents();
+ },
+ initializeCollections: function () {
+ this.auditModel = new VAuditLog();
+ this.collection = new VAuditLogList([], {
+ state: {
+ firstPage: 0,
+ pageSize: 25
+ }
+ });
- /**
- * intialize a new LogLevelView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options,'globalVent'));
- this.defaultParams = ViewUtils.getDefaultParamsForHierarchy();
- delete this.defaultParams.level;
- this.vent = new Backbone.Wreqr.EventAggregator();
- this.initializeCollections();
- this.columns = [];
- this.bindEvents();
- },
- initializeCollections : function(){
- this.auditModel = new VAuditLog();
- this.collection = new VAuditLogList([],{
- state: {
- firstPage: 0,
- pageSize: 25
- }
- });
+ this.componentsList = new VGroupList([], {
+ state: {
+ firstPage: 0,
+ pageSize: 99999
+ }
+ });
+ this.componentsList.url = Globals.baseURL + "audit/logs/components";
+ },
+ bindEvents: function () {
+ this.listenTo(this.componentsList, "reset", function (col, abc) {
+ this.setupSelect2Fields(col, "type", 'type', 'excludeComponents', 'Exclude Components');
+ this.setupSelect2Fields(col, "type", 'type', 'includeComponents', 'Include Components');
+ }, this);
+ this.listenTo(this.vent, "search:audit:query auditComponents:include auditComponents:exclude search:audit:include search:audit:exclude logtime:filter", function (value) {
+ _.extend(this.defaultParams, value);
+ this.fetchAuditLogs(value);
+ }, this);
+ this.listenTo(this.vent, "reinitialize:filter:mustBe", function (value) {
+ this.reinitializeFilterMustBe(value);
+ }, this);
+ this.listenTo(this.vent, "reinitialize:filter:mustNot", function (value) {
+ this.reinitializeFilterMustNot(value);
+ }, this);
- this.componentsList = new VGroupList([],{
- state: {
- firstPage: 0,
- pageSize: 99999
- }
- });
- this.componentsList.url = Globals.baseURL + "audit/logs/components";
- },
- bindEvents : function(){
- this.listenTo(this.componentsList, "reset", function(col, abc){
- this.setupSelect2Fields(col,"type", 'type', 'excludeComponents', 'Exclude Components');
- this.setupSelect2Fields(col,"type", 'type', 'includeComponents', 'Include Components');
- }, this);
- this.listenTo(this.vent,"search:audit:query auditComponents:include auditComponents:exclude search:audit:include search:audit:exclude logtime:filter",function(value){
- _.extend(this.defaultParams,value);
- this.fetchAuditLogs(value);
- }, this);
- this.listenTo(this.vent,"reinitialize:filter:mustBe",function(value){
- this.reinitializeFilterMustBe(value);
- },this);
- this.listenTo(this.vent,"reinitialize:filter:mustNot",function(value){
- this.reinitializeFilterMustNot(value);
- },this);
+ this.listenTo(this.globalVent, "reinitialize:auditLogs", function (options) {
+ this.vent.trigger("reinitialize:filter:mustNot reinitialize:filter:mustBe reinitialize:filter:logtime " +
+ "reinitialize:TopTenGraph", options);
+ this.fetchAuditLogs(options);
+ }, this);
- this.listenTo(this.globalVent,"reinitialize:auditLogs",function(options){
- this.vent.trigger("reinitialize:filter:mustNot reinitialize:filter:mustBe reinitialize:filter:logtime "+
- "reinitialize:TopTenGraph",options);
- this.fetchAuditLogs(options);
- },this);
+ },
+ onRender: function () {
+ this.renderHistogram();
+ this.renderAuditAggregatedInfo();
+ this.fetchAuditColumns();
+ this.fetchAuditLogs((this.defaultParams) ? this.defaultParams : {q: "*:*"});
+ this.componentsList.fetch({reset: true});
+ },
+ renderHistogram: function () {
+ var that = this;
+ require(['views/graphs/GraphLayoutView'], function (GraphLayoutView) {
+ that.RAuditLine.show(new GraphLayoutView({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams,
+ viewType: Globals.graphType.MULTILINE.value,
+ showDatePicker: true,
+ futureDate: false
+ }));
+ })
+ },
+ renderAuditAggregatedInfo: function () {
+ var that = this;
+ require(['views/audit/AuditAggregatedView'], function (AuditAggregatedView) {
+ that.RAuditAggregated.show(new AuditAggregatedView({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams
+ }));
+ })
- },
- onRender : function(){
- this.renderHistogram();
- this.renderAuditAggregatedInfo();
- this.fetchAuditColumns();
- this.fetchAuditLogs((this.defaultParams) ? this.defaultParams : {q:"*:*"});
- this.componentsList.fetch({reset:true});
- //this.startPoll();
- },
- renderHistogram : function(){
- var that = this;
- require(['views/graphs/GraphLayoutView'],function(GraphLayoutView){
- that.RAuditLine.show(new GraphLayoutView({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams,
- //parentView : this,
- viewType : Globals.graphType.MULTILINE.value,
- showDatePicker:true,
- futureDate : false
- }));
- })
- },
- renderAuditAggregatedInfo : function(){
- var that = this;
- require(['views/audit/AuditAggregatedView'],function(AuditAggregatedView){
- that.RAuditAggregated.show(new AuditAggregatedView({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams
- }));
- })
+ },
+ fetchAuditColumns: function () {
+ var that = this;
+ this.collection.getAuditSchemaFieldsName({}, {
+ beforeSend: function () {
+ that.$("#loaderAudit").show();
+ },
+ success: function (data) {
+ that.columns = ViewUtils.getLogSchemaFields(data, Globals.defaultAuditLogMappings, Globals.defaultAuditLogExcludes);
+ },
+ error: function (error, data, status) {
+ var obj = JSON.parse(error.responseText);
+ if (obj)
+ Utils.notifyError({content: obj.msgDesc});
+ },
+ complete: function () {
+ that.renderAuditTable();
+ that.renderVSSearch();
+ that.$("#loaderAudit").hide();
+ }
+ });
+ },
+ fetchAuditLogs: function (params) {
+ $.extend(this.collection.queryParams, params);
+ this.collection.getFirstPage({reset: true});
+ },
+ renderVSSearch: function () {
+ var that = this;
+ require(['views/tabs/VisualSearchView'], function (VisualSearchView) {
- },
- fetchAuditColumns : function(){
- var that =this;
- this.collection.getAuditSchemaFieldsName({},{
- beforeSend : function(){
- that.$("#loaderAudit").show();
- },
- success : function(data){
- that.columns = data;
- },
- error : function(error,data,status){
- var obj = JSON.parse(error.responseText);
- if(obj)
- Utils.notifyError({content:obj.msgDesc});
- },
- complete : function(){
- that.renderAuditTable();
- that.renderVSSearch();
- that.$("#loaderAudit").hide();
- }
- });
- },
- fetchAuditLogs : function(params){
- $.extend(this.collection.queryParams,params);
- this.collection.getFirstPage({reset:true});
- },
- renderVSSearch : function(){
- var that = this;
- require(['views/tabs/VisualSearchView'], function(VisualSearchView){
-
- _.each(that.columns,function(v,i){
- if(v.toLowerCase().indexOf("time") > 0 ){
- //that.columns.splice(i, 1);
- delete that.columns[v]
- }
- });
- that.RVisualSearchInc.show(new VisualSearchView({
- viewName : "includeColumns",
- placeholder : "Include Search",
- vent : that.vent,
- globalVent:that.globalVent,
- customOptions : _.values(that.columns),
- eventName : "search:audit:include",
- myFormatData : function(query,searchCollection){
- var obj=[];
- searchCollection.each(function(m){
- var data = {};
- data[m.get("category")] = Utils.manipulateValueForAddingAstrik(m.get("value"));
- obj.push(data);
- });
- return {
- includeQuery : JSON.stringify(obj),
- query : query
- }
- }
- }));
- that.RVisualSearchEx.show(new VisualSearchView({
- placeholder : "Exclude Search",
- vent : that.vent,
- globalVent:that.globalVent,
- customOptions : _.values(that.columns),
- eventName : "search:audit:exclude",
- myFormatData : function(query,searchCollection){
- var obj=[];
- searchCollection.each(function(m){
- var data = {};
- data[m.get("category")] = Utils.manipulateValueForAddingAstrik(m.get("value"));
- obj.push(data);
- });
- return {
- excludeQuery : JSON.stringify(obj),
- query : query
- }
- }
- }));
- });
- },
- renderAuditTable : function(){
- var that = this;
- require(['views/common/TableLayout'], function(TableLayout){
- var cols = new Backgrid.Columns(that.getColumns());
- that.RAuditTable.show(new TableLayout({
- columns: cols,
- collection: that.collection,
- includeFilter : false,
- includePagination : true,
- includePageSize : true,
- includeFooterRecords : true,
- includeColumnManager : true,
- columnOpts : {
- initialColumnsVisible: 9,
- saveState : false
- },
- gridOpts : {
- className : "table table-bordered table-hover table-condensed backgrid",
- emptyText : 'No records found!'
- },
- filterOpts : {},
- paginatorOpts : {}
- }));
- });
- },
- getColumns : function(){
- var cols = {};
- var that = this;
- _.each(this.columns,function(value,col){
- cols[col] = {
- label:value,
- cell: "String",
- sortType: 'toggle',
- editable: false,
- }
- });
- var columns = {
- evtTime : {
- label : "Event Time",
- cell: "String",
- sortType: 'toggle',
- editable: false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model){
- return moment(rawValue).format("YYYY-MM-DD HH:mm:ss,SSS");
- }
- })
- },
- reqUser : {
- label : "User",
- cell: "String",
- sortType: 'toggle',
- editable: false
- },
- repo : {
- label : 'Repo',
- cell: "String",
- sortType: 'toggle',
- editable:false
- },
- resource : {
- label : 'Resource',
- cell: "String",
- sortType: 'toggle',
- editable:false
- },
- access : {
- label : 'Access Type',
- cell: "String",
- sortType: 'toggle',
- editable:false
- },
- result : {
- label : 'Result',
- cell: "String",
- sortType: 'toggle',
- editable:false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model){
- return (rawValue === 1) ? "Allowed" : "Denied";
- }
- })
- },
- enforcer : {
- label : 'Access Enforcer',
- cell: "String",
- sortType: 'toggle',
- editable:false
- },
- cliIP : {
- label : 'Client IP',
- cell: "String",
- sortType: 'toggle',
- editable:false
- },
- event_count : {
- label : 'Event Count',
- cell: "String",
- sortType: 'toggle',
- editable:false
- }
- };
- _.each(cols,function(c,k){
- if(columns[k] == undefined && k != "_version_"){
- columns[k] = c;
- }else{
- if(columns[k] && columns[k].label){
- columns[k].label = c.label;
- }
- }
- })
- /*_.each(columns,function(c,k){
- if(columns[k] == undefined && k != "_version_"){
- columns[k] = c;
- }
- })*/
- return this.collection.constructor.getTableCols(columns, this.collection);
- },
- onAuditTabRefresh : function(e){
- ViewUtils.setLatestTimeParams(this.defaultParams);
- //this.fetchAuditColumns();
- $.extend(this.collection.queryParams,this.defaultParams);
- this.collection.fetch({reset:true});
- this.vent.trigger("tab:refresh",this.defaultParams);
- },
- onViewTypeChange: function(e){
- var that = this;
- var val = that.$("[name='viewTypeAudit']:checked").val();
- this.toggleViewType(val);
- },
- toggleViewType : function(val){
- if(val === "A"){
- this.$("[data-id='auditTable']").show();
- this.$('[data-id="auditAggregated"]').hide();
- }else{
- this.$('[data-id="auditAggregated"]').show();
- this.$("[data-id='auditTable']").hide();
- if(this.RAuditAggregated.currentView)
- this.RAuditAggregated.currentView.$el.resize();
- }
- },
- setupSelect2Fields : function(col, idKey, textKey, selectTagId, placeHolder){
- var that = this, data = [];
- data = _.pluck(col.models, 'attributes');
-// data = data.map(function(obj){
-// return {id : obj[idKey], text : obj[textKey]}
-// })
- //data.unshift({'id': null, 'text': null});
- for(var i=0;i < data.length;i++){
- data[i].id = data[i].type;
- }
- this.ui[selectTagId].select2({
- placeholder: (placeHolder) ? placeHolder :'Select',
- tags:true,
- allowClear : true,
- width: '100%',
- data: { results: data, text: textKey},
- formatSelection: function(item){
- return item[textKey];
- },
- formatResult: function(item){
- return item[textKey];
- }
- }).on("change",function(e){
- var data = that.ui[selectTagId].select2("data").map(function(d){return d.type});
- if(selectTagId === "excludeComponents"){
- that.vent.trigger("auditComponents:exclude",{mustNot:data.toString()});
- }
- if(selectTagId === "includeComponents")
- that.vent.trigger("auditComponents:include",{mustBe:data.toString()});
- });
- },
- startPoll : function(){
- var that = this;
- setInterval(function(){
- that.pollLiveFeed();
- },5000);
- },
- pollLiveFeed : function(){
- var that = this;
- if(this.pollXhr){
- if(this.pollXhr.readyState > 0 && this.pollXhr.readyState < 4)
- return
- }
- this.pollXhr = this.auditModel.auditLiveFeed({},{
- beforeSend : function(){
- that.$("#loaderFeed").show();
- },
- success : function(data){
- var dd=[];
- that.$("#spark").parent().show();
- _.each(data.vnameValues,function(d){
- dd.push(d.value);
- });
- that.$("#spark").sparkline(dd, {lineColor: '#5A8DB6',width:"100px",
- /*tooltipFormatter : function(){
- console.log(arguments)
- }*/});
- },
- error : function(){
- that.$("#spark").parent().hide();
- },
- complete : function(){
- setTimeout(function(){
- that.$("#loaderFeed").hide();
- },1000);
- }
- });
- },
- reinitializeFilterMustBe : function(values){
- if(values.mustBe){
- this.ui.includeComponents.select2('val',values.mustBe.split(","));
- }else{
- this.ui.includeComponents.select2('val',[]);
- }
- },
- reinitializeFilterMustNot : function(values){
- if(values.mustNot){
- this.ui.excludeComponents.select2('val',values.mustNot.split(","));
- }else{
- this.ui.excludeComponents.select2('val',[]);
- }
- }
- });
+ _.each(that.columns, function (v, i) {
+ if (v.toLowerCase().indexOf("time") > 0) {
+ delete that.columns[v]
+ }
+ });
+ that.RVisualSearchInc.show(new VisualSearchView({
+ viewName: "includeColumns",
+ placeholder: "Include Search",
+ vent: that.vent,
+ globalVent: that.globalVent,
+ customOptions: _.values(that.columns),
+ eventName: "search:audit:include",
+ myFormatData: function (query, searchCollection) {
+ var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedAuditLogMappings, true);
+ return {
+ includeQuery: JSON.stringify(obj),
+ query: query
+ }
+ }
+ }));
+ that.RVisualSearchEx.show(new VisualSearchView({
+ placeholder: "Exclude Search",
+ vent: that.vent,
+ globalVent: that.globalVent,
+ customOptions: _.values(that.columns),
+ eventName: "search:audit:exclude",
+ myFormatData: function (query, searchCollection) {
+ var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedAuditLogMappings, true);
+ return {
+ excludeQuery: JSON.stringify(obj),
+ query: query
+ }
+ }
+ }));
+ });
+ },
+ renderAuditTable: function () {
+ var that = this;
+ require(['views/common/TableLayout'], function (TableLayout) {
+ var cols = new Backgrid.Columns(that.getColumns());
+ that.RAuditTable.show(new TableLayout({
+ columns: cols,
+ collection: that.collection,
+ includeFilter: false,
+ includePagination: true,
+ includePageSize: true,
+ includeFooterRecords: true,
+ includeColumnManager: true,
+ columnOpts: {
+ initialColumnsVisible: 9,
+ saveState: false
+ },
+ gridOpts: {
+ className: "table table-bordered table-hover table-condensed backgrid",
+ emptyText: 'No records found!'
+ },
+ filterOpts: {},
+ paginatorOpts: {}
+ }));
+ });
+ },
+ getColumns: function () {
+ var cols = {};
+ var that = this;
+ var columns = {
+ evtTime: {
+ label: "Event Time",
+ cell: "String",
+ sortType: 'toggle',
+ editable: false,
+ formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+ fromRaw: function (rawValue, model) {
+ return moment(rawValue).format("YYYY-MM-DD HH:mm:ss,SSS");
+ }
+ })
+ },
+ reqUser: {
+ label: "User",
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ },
+ repo: {
+ label: 'Repo',
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ },
+ resource: {
+ label: 'Resource',
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ },
+ access: {
+ label: 'Access Type',
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ },
+ result: {
+ label: 'Result',
+ cell: "String",
+ sortType: 'toggle',
+ editable: false,
+ formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+ fromRaw: function (rawValue, model) {
+ return (rawValue === 1) ? "Allowed" : "Denied";
+ }
+ })
+ },
+ enforcer: {
+ label: 'Access Enforcer',
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ },
+ cliIP: {
+ label: 'Client IP',
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ },
+ event_count: {
+ label: 'Event Count',
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ }
+ };
+ _.each(this.columns, function(value){
+ var name = Globals.invertedAuditLogMappings[value];
+ if (columns[name] === undefined && value != "_version_") {
+ var columnObj = {
+ name: Globals.invertedAuditLogMappings[value],
+ label:value,
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ };
+ columns[name] = columnObj;
+ } else {
+ if (columns[name] && columns[name].label) {
+ columns[name].label = value;
+ }
+ }
+ });
+ return this.collection.constructor.getTableCols(columns, this.collection);
+ },
+ onAuditTabRefresh: function (e) {
+ ViewUtils.setLatestTimeParams(this.defaultParams);
+ $.extend(this.collection.queryParams, this.defaultParams);
+ this.collection.fetch({reset: true});
+ this.vent.trigger("tab:refresh", this.defaultParams);
+ },
+ onViewTypeChange: function (e) {
+ var that = this;
+ var val = that.$("[name='viewTypeAudit']:checked").val();
+ this.toggleViewType(val);
+ },
+ toggleViewType: function (val) {
+ if (val === "A") {
+ this.$("[data-id='auditTable']").show();
+ this.$('[data-id="auditAggregated"]').hide();
+ } else {
+ this.$('[data-id="auditAggregated"]').show();
+ this.$("[data-id='auditTable']").hide();
+ if (this.RAuditAggregated.currentView)
+ this.RAuditAggregated.currentView.$el.resize();
+ }
+ },
+ setupSelect2Fields: function (col, idKey, textKey, selectTagId, placeHolder) {
+ var that = this, data = [];
+ data = _.pluck(col.models, 'attributes');
+ for (var i = 0; i < data.length; i++) {
+ data[i].id = data[i].type;
+ }
+ this.ui[selectTagId].select2({
+ placeholder: (placeHolder) ? placeHolder : 'Select',
+ tags: true,
+ allowClear: true,
+ width: '100%',
+ data: {results: data, text: textKey},
+ formatSelection: function (item) {
+ return item[textKey];
+ },
+ formatResult: function (item) {
+ return item[textKey];
+ }
+ }).on("change", function (e) {
+ var data = that.ui[selectTagId].select2("data").map(function (d) {
+ return d.type
+ });
+ if (selectTagId === "excludeComponents") {
+ that.vent.trigger("auditComponents:exclude", {mustNot: data.toString()});
+ }
+ if (selectTagId === "includeComponents")
+ that.vent.trigger("auditComponents:include", {mustBe: data.toString()});
+ });
+ },
+ startPoll: function () {
+ var that = this;
+ setInterval(function () {
+ that.pollLiveFeed();
+ }, 5000);
+ },
+ pollLiveFeed: function () {
+ var that = this;
+ if (this.pollXhr) {
+ if (this.pollXhr.readyState > 0 && this.pollXhr.readyState < 4)
+ return
+ }
+ this.pollXhr = this.auditModel.auditLiveFeed({}, {
+ beforeSend: function () {
+ that.$("#loaderFeed").show();
+ },
+ success: function (data) {
+ var dd = [];
+ that.$("#spark").parent().show();
+ _.each(data.vnameValues, function (d) {
+ dd.push(d.value);
+ });
+ that.$("#spark").sparkline(dd, {lineColor: '#5A8DB6', width: "100px"});
+ },
+ error: function () {
+ that.$("#spark").parent().hide();
+ },
+ complete: function () {
+ setTimeout(function () {
+ that.$("#loaderFeed").hide();
+ }, 1000);
+ }
+ });
+ },
+ reinitializeFilterMustBe: function (values) {
+ if (values.mustBe) {
+ this.ui.includeComponents.select2('val', values.mustBe.split(","));
+ } else {
+ this.ui.includeComponents.select2('val', []);
+ }
+ },
+ reinitializeFilterMustNot: function (values) {
+ if (values.mustNot) {
+ this.ui.excludeComponents.select2('val', values.mustNot.split(","));
+ } else {
+ this.ui.excludeComponents.select2('val', []);
+ }
+ }
+ });
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js
index e43f239..83b756b 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/CustomBackgrid.js
@@ -252,7 +252,6 @@ define(['require',
initialize: function (options) {
var args = Array.prototype.slice.apply(arguments);
Backgrid.Header.prototype.initialize.apply(this, args);
-
this.searchRow = new HeaderRow({
columns: this.columns,
collection: this.collection
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js
index e88afea..1e469d5 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/Header.js
@@ -339,12 +339,8 @@ define(['require',
var gMessage = logMessagesList.map(function(e) {
return e.message
- })
- this.setNotificationCount(componentList.length, gMessage.length);
- this.globalVent.trigger("globalExclusion:component:message", {
- gMustNot: (componentList.length != 0) ? (componentList.join()) : (""),
- gEMessage: (gMessage.length != 0) ? (gMessage.join(Globals.splitToken)) : ("")
});
+ this.setNotificationCount(componentList.length, gMessage.length);
},
/** closing the movable/resizable popup */
onDialogClosed: function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js
index f46d94b..0cdef28 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/common/ProfileBar.js
@@ -22,9 +22,8 @@ define(['require',
'backbone',
'App',
'communicator',
- 'mgrs/SessionMgr',
'hbs!tmpl/common/ProfileBar_tmpl'
-],function(require,Backbone,App,Communicator,SessionMgr,ProfileBar_tmpl){
+],function(require,Backbone,App,Communicator,ProfileBar_tmpl){
'use strict';
var ProfileBar = Backbone.Marionette.ItemView.extend(
[6/6] ambari git commit: AMBARI-18310. Refactor logsearch portal code
- part 3 (oleewere)
Posted by ol...@apache.org.
AMBARI-18310. Refactor logsearch portal code - part 3 (oleewere)
Change-Id: Ibb5fc43360da84ae8d21f064d39f0f1ef7b82e1e
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3013589a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3013589a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3013589a
Branch: refs/heads/branch-dev-logsearch
Commit: 3013589a1b9e99f9014e5fbaac28edcf4679669b
Parents: 4c19f4a
Author: oleewere <ol...@gmail.com>
Authored: Sat Sep 10 21:15:02 2016 +0200
Committer: oleewere <ol...@gmail.com>
Committed: Mon Sep 12 13:16:01 2016 +0200
----------------------------------------------------------------------
.../test-output/service-log-schema.json | 38 +-
.../ambari/logsearch/common/ConfigHelper.java | 106 ---
.../logsearch/common/ExternalServerClient.java | 7 +-
.../logsearch/common/LogSearchConstants.java | 14 +-
.../logsearch/common/PropertiesHelper.java | 44 -
.../ambari/logsearch/common/PropertyMapper.java | 59 --
.../ambari/logsearch/conf/AuthConfig.java | 97 ---
.../ambari/logsearch/conf/AuthPropsConfig.java | 97 +++
.../logsearch/conf/SolrAuditLogConfig.java | 181 ----
.../logsearch/conf/SolrAuditLogPropsConfig.java | 142 +++
.../ambari/logsearch/conf/SolrColumnConfig.java | 36 -
.../ambari/logsearch/conf/SolrConfig.java | 88 +-
.../logsearch/conf/SolrConnectionConfig.java | 49 --
.../conf/SolrConnectionPropsConfig.java | 49 ++
.../ambari/logsearch/conf/SolrPropsConfig.java | 50 ++
.../logsearch/conf/SolrServiceLogConfig.java | 144 ---
.../conf/SolrServiceLogPropsConfig.java | 94 ++
.../ambari/logsearch/conf/SolrUserConfig.java | 104 ---
.../logsearch/conf/SolrUserPropsConfig.java | 104 +++
.../ambari/logsearch/dao/AuditSolrDao.java | 59 +-
.../logsearch/dao/ServiceLogsSolrDao.java | 47 +-
.../ambari/logsearch/dao/SolrAliasDao.java | 123 +++
.../ambari/logsearch/dao/SolrCollectionDao.java | 259 ++++++
.../ambari/logsearch/dao/SolrDaoBase.java | 508 +----------
.../logsearch/dao/SolrSchemaFieldDao.java | 159 ++++
.../ambari/logsearch/dao/UserConfigSolrDao.java | 63 +-
.../apache/ambari/logsearch/dao/UserDao.java | 10 +-
.../ambari/logsearch/doc/DocConstants.java | 21 +-
.../logsearch/graph/GraphDataGenerator.java | 2 +-
.../logsearch/manager/AuditLogsManager.java | 162 +---
.../logsearch/manager/LogFileManager.java | 155 ----
.../ambari/logsearch/manager/PublicManager.java | 6 +-
.../logsearch/manager/ServiceLogsManager.java | 122 +--
.../logsearch/manager/UserConfigManager.java | 1 -
.../model/request/LogFileParamDefinition.java | 45 -
.../request/LogFileTailParamDefinition.java | 32 -
.../model/request/LogParamDefinition.java | 13 -
.../request/ServiceLogFileParamDefinition.java | 38 -
.../request/ServiceLogParamDefinition.java | 17 -
.../model/request/impl/BaseLogRequest.java | 25 -
.../request/impl/BaseServiceLogRequest.java | 39 -
.../model/request/impl/LogFileRequest.java | 67 --
.../model/request/impl/LogFileTailRequest.java | 40 -
.../model/request/impl/ServiceGraphRequest.java | 2 +-
.../request/impl/ServiceLogExportRequest.java | 2 +-
.../request/impl/ServiceLogFileRequest.java | 54 --
.../model/request/impl/ServiceLogRequest.java | 2 +-
.../impl/ServiceLogTruncatedRequest.java | 2 +-
.../ambari/logsearch/query/QueryGeneration.java | 96 +-
.../logsearch/query/QueryGenerationBase.java | 28 -
.../query/SearchCriteriaConstants.java | 8 -
.../AbstractCommonAuditLogRequestConverter.java | 4 -
...bstractCommonServiceLogRequestConverter.java | 6 -
.../converter/LogFileRequestConverter.java | 37 -
.../converter/LogFileTailRequestConverter.java | 38 -
.../converter/ServiceGraphRequestConverter.java | 2 -
.../ServiceLogExportRequestConverter.java | 2 -
.../ServiceLogFileRequestConverter.java | 36 -
.../converter/ServiceLogRequestConverter.java | 2 -
.../ServiceLogTruncatedRequestConverter.java | 2 -
.../model/CommonServiceLogSearchCriteria.java | 8 -
.../query/model/LogFileSearchCriteria.java | 52 --
.../query/model/LogFileTailSearchCriteria.java | 32 -
.../logsearch/query/model/SearchCriteria.java | 9 +
.../model/ServiceAnyGraphSearchCriteria.java | 2 +-
.../query/model/ServiceGraphSearchCriteria.java | 2 +-
.../model/ServiceLogExportSearchCriteria.java | 2 +-
.../model/ServiceLogFileSearchCriteria.java | 40 -
.../query/model/ServiceLogSearchCriteria.java | 2 +-
.../ServiceLogTruncatedSearchCriteria.java | 2 +-
.../logsearch/rest/AuditLogsResource.java | 1 -
.../ambari/logsearch/rest/LogFileResource.java | 69 --
.../logsearch/rest/ServiceLogsResource.java | 28 +-
...rchExternalServerAuthenticationProvider.java | 8 +-
.../LogsearchFileAuthenticationProvider.java | 6 +-
.../LogsearchLdapAuthenticationProvider.java | 8 +-
.../LogsearchSimpleAuthenticationProvider.java | 6 +-
.../src/main/resources/default.properties | 21 -
.../src/main/webapp/scripts/App.js | 4 +-
.../collection_bases/VAuditLogListBase.js | 2 +-
.../scripts/collection_bases/VLogListBase.js | 19 +-
.../scripts/collections/BaseCollection.js | 1 -
.../scripts/collections/SchemaFieldList.js | 29 +
.../src/main/webapp/scripts/mgrs/SessionMgr.js | 137 ---
.../src/main/webapp/scripts/utils/Globals.js | 158 ++--
.../src/main/webapp/scripts/utils/ViewUtils.js | 423 ++++-----
.../scripts/views/audit/AuditTabLayoutView.js | 858 +++++++++---------
.../scripts/views/common/CustomBackgrid.js | 1 -
.../main/webapp/scripts/views/common/Header.js | 6 +-
.../webapp/scripts/views/common/ProfileBar.js | 3 +-
.../dashboard/BubbleGraphTableLayoutView.js | 164 +---
.../views/dashboard/ComponentListView.js | 4 +-
.../scripts/views/dashboard/DashboardView.js | 4 -
.../scripts/views/dashboard/HostListView.js | 4 +-
.../scripts/views/dashboard/MainLayoutView.js | 15 +-
.../scripts/views/dialog/DetailLogFileView.js | 4 +-
.../views/filter/CreateLogfeederFilterView.js | 6 +-
.../webapp/scripts/views/tabs/ComparisonView.js | 15 +-
.../views/tabs/HierarchyTabLayoutView.js | 871 +++++++++----------
.../webapp/scripts/views/tabs/LogFileView.js | 73 +-
.../main/webapp/scripts/views/tabs/TreeView.js | 6 +-
.../scripts/views/tabs/VisualSearchView.js | 437 ++++------
.../src/main/webapp/static/schema_fields.json | 71 ++
.../dashboard/MainLayoutView_tmpl.html | 121 ---
.../main/webapp/templates/helpers/Helpers.js | 39 -
.../ambari/logsearch/dao/AuditSolrDaoTest.java | 99 ---
.../logsearch/dao/ServiceLogsSolrDaoTest.java | 95 --
.../ambari/logsearch/dao/SolrDaoBaseTest.java | 306 -------
.../logsearch/dao/UserConfigSolrDaoTest.java | 164 ----
.../test-config/logsearch/logsearch.properties | 2 -
110 files changed, 2946 insertions(+), 5332 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-it/src/test/resources/test-output/service-log-schema.json
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-it/src/test/resources/test-output/service-log-schema.json b/ambari-logsearch/ambari-logsearch-it/src/test/resources/test-output/service-log-schema.json
index 9efa58b..2933123 100644
--- a/ambari-logsearch/ambari-logsearch-it/src/test/resources/test-output/service-log-schema.json
+++ b/ambari-logsearch/ambari-logsearch-it/src/test/resources/test-output/service-log-schema.json
@@ -1,18 +1,24 @@
{
- "log_message": "Log Message",
- "bundle_id": "Bundle Id",
- "case_id": "Case Id",
- "cluster": "Cluster",
- "event_count": "Event Count",
- "file": "File",
- "host": "Host",
- "id": "Id",
- "ip": "IP",
- "level": "Level",
- "logfile_line_number": "Logfile Line Number",
- "logger_name": "Logger Name",
- "method": "method",
- "path": "Path",
- "text": "Text",
- "type": "Type"
+ "logfile_line_number": "tint",
+ "logtime": "tdate",
+ "text": "text_std_token_lower_case",
+ "host": "key_lower_case",
+ "seq_num": "tlong",
+ "logtype": "key_lower_case",
+ "rowtype": "key_lower_case",
+ "log_message": "text_std_token_lower_case",
+ "line_number": "tint",
+ "type": "key_lower_case",
+ "ip": "string",
+ "id": "string",
+ "thread_name": "key_lower_case",
+ "level": "key_lower_case",
+ "file": "key_lower_case",
+ "bundle_id": "key_lower_case",
+ "path": "key_lower_case",
+ "cluster": "key_lower_case",
+ "case_id": "key_lower_case",
+ "logger_name": "key_lower_case",
+ "method": "key_lower_case",
+ "event_count": "tlong"
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ConfigHelper.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ConfigHelper.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ConfigHelper.java
deleted file mode 100644
index a3a71ea..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ConfigHelper.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.common;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.manager.ManagerBase;
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.log4j.Logger;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONObject;
-
-public class ConfigHelper {
- private static final Logger logger = Logger.getLogger(ManagerBase.class);
-
- private ConfigHelper() {
- throw new UnsupportedOperationException();
- }
-
- public static void extractSchemaFieldsName(String responseString, HashMap<String, String> schemaFieldsNameMap,
- HashMap<String, String> schemaFieldTypeMap) {
- try {
- JSONObject jsonObject = new JSONObject(responseString);
- JSONObject schemajsonObject = jsonObject.getJSONObject("schema");
- JSONArray jsonArrayList = schemajsonObject.getJSONArray("fields");
- JSONArray fieldTypeJsonArray = schemajsonObject
- .getJSONArray("fieldTypes");
- if (jsonArrayList == null) {
- return;
- }
- if (fieldTypeJsonArray == null) {
- return;
- }
- HashMap<String, String> _schemaFieldTypeMap = new HashMap<String, String>();
- HashMap<String, String> _schemaFieldsNameMap = new HashMap<String, String>();
- for (int i = 0; i < fieldTypeJsonArray.length(); i++) {
- JSONObject typeObject = fieldTypeJsonArray.getJSONObject(i);
- String name = typeObject.getString("name");
- String fieldTypeJson = typeObject.toString();
- _schemaFieldTypeMap.put(name, fieldTypeJson);
- }
-
- for (int i = 0; i < jsonArrayList.length(); i++) {
- JSONObject explrObject = jsonArrayList.getJSONObject(i);
- String name = explrObject.getString("name");
- String type = explrObject.getString("type");
- if (!name.contains("@") && !name.startsWith("_") && !name.contains("_md5") && !name.contains("_ms") &&
- !name.contains(LogSearchConstants.NGRAM_SUFFIX) && !name.contains("tags") && !name.contains("_str")) {
- _schemaFieldsNameMap.put(name, type);
- }
- }
- schemaFieldsNameMap.clear();
- schemaFieldTypeMap.clear();
- schemaFieldsNameMap.putAll(_schemaFieldsNameMap);
- schemaFieldTypeMap.putAll(_schemaFieldTypeMap);
- } catch (Exception e) {
- logger.error(e + "Credentials not specified in logsearch.properties " + MessageEnums.ERROR_SYSTEM);
- }
- }
-
- @SuppressWarnings("rawtypes")
- public static void getSchemaFieldsName(String excludeArray[], List<String> fieldNames, SolrDaoBase solrDaoBase) {
- if (!solrDaoBase.schemaFieldsNameMap.isEmpty()) {
- Iterator iteratorSechmaFieldsName = solrDaoBase.schemaFieldsNameMap.entrySet().iterator();
- while (iteratorSechmaFieldsName.hasNext()) {
- Map.Entry fieldName = (Map.Entry) iteratorSechmaFieldsName.next();
- String field = "" + fieldName.getKey();
- if (!isExclude(field, excludeArray)) {
- fieldNames.add(field);
- }
- }
- }
- }
-
- private static boolean isExclude(String name, String excludeArray[]) {
- if (!ArrayUtils.isEmpty(excludeArray)) {
- for (String exclude : excludeArray) {
- if (name.equals(exclude)){
- return true;
- }
- }
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
index 2590dfe..9682a3d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
@@ -27,13 +27,12 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
-import org.apache.ambari.logsearch.conf.AuthConfig;
+import org.apache.ambari.logsearch.conf.AuthPropsConfig;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.glassfish.jersey.client.JerseyClient;
import org.glassfish.jersey.client.JerseyClientBuilder;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.glassfish.jersey.filter.LoggingFilter;
import org.springframework.stereotype.Component;
/**
@@ -51,7 +50,7 @@ public class ExternalServerClient {
};
@Inject
- private AuthConfig authConfig;
+ private AuthPropsConfig authPropsConfig;
/**
* Send GET request to an external server
@@ -59,7 +58,7 @@ public class ExternalServerClient {
public Object sendGETRequest(String url, Class klass, MultivaluedMap<String, String> queryParam,
String username, String password)
throws Exception {
- url = authConfig.getExternalAuthHostUrl() + url;
+ url = authPropsConfig.getExternalAuthHostUrl() + url;
JerseyClient client = localJerseyClient.get();
HttpAuthenticationFeature authFeature = HttpAuthenticationFeature.basicBuilder()
.credentials(username, password)
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
index 36ecb81..d9d3b86 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
@@ -73,7 +73,6 @@ public class LogSearchConstants {
//operation
public static final String EXCLUDE_QUERY = "excludeQuery";
public static final String INCLUDE_QUERY = "includeQuery";
- public static final String COLUMN_QUERY = "columnQuery";
// Seprator's
public static final String I_E_SEPRATOR = "\\|i\\:\\:e\\|";
@@ -139,13 +138,8 @@ public class LogSearchConstants {
public static final String REQUEST_PARAM_FIELD = "field";
public static final String REQUEST_PARAM_FORMAT = "format";
public static final String REQUEST_PARAM_LAST_PAGE = "lastPage";
- public static final String REQUEST_PARAM_LOG_TYPE = "logType";
- public static final String REQUEST_PARAM_COMPONENT = "component";
- public static final String REQUEST_PARAM_HOST = "host";
- public static final String REQUEST_PARAM_TAIL_SIZE = "tailSize";
- public static final String REQUEST_PARAM_COLUMN_QUERY = "columnQuery";
public static final String REQUEST_PARAM_I_MESSAGE = "iMessage";
- public static final String REQUEST_PARAM_G_E_MESSAGE = "gEMessage";
+ public static final String REQUEST_PARAM_E_MESSAGE = "eMessage";
public static final String REQUEST_PARAM_MUST_BE = "mustBe";
public static final String REQUEST_PARAM_MUST_NOT = "mustNot";
public static final String REQUEST_PARAM_INCLUDE_QUERY = "includeQuery";
@@ -153,13 +147,7 @@ public class LogSearchConstants {
public static final String REQUEST_PARAM_ID = "id";
public static final String REQUEST_PARAM_SCROLL_TYPE = "scrollType";
public static final String REQUEST_PARAM_NUMBER_ROWS = "numberRows";
- public static final String REQUEST_PARAM_HOST_LOG_FILE = "host";
- public static final String REQUEST_PARAM_COMPONENT_LOG_FILE = "component";
public static final String REQUEST_PARAM_LEVEL = "level";
- public static final String REQUEST_PARAM_ADVANCED_SEARCH = "advancedSearch";
- public static final String REQUEST_PARAM_TREE_PARAMS = "treeParams";
- public static final String REQUEST_PARAM_E_MESSAGE = "eMessage";
- public static final String REQUEST_PARAM_G_MUST_NOT = "gMustNot";
public static final String REQUEST_PARAM_HOST_NAME = "host_name";
public static final String REQUEST_PARAM_COMPONENT_NAME = "component_name";
public static final String REQUEST_PARAM_FILE_NAME = "file_name";
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertiesHelper.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertiesHelper.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertiesHelper.java
index adb0699..1844d8f 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertiesHelper.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertiesHelper.java
@@ -124,50 +124,6 @@ public class PropertiesHelper extends PropertyPlaceholderConfigurer {
}
}
- public static Integer getIntProperty(String key, int defaultValue) {
- if (key == null) {
- return null;
- }
- String rtrnVal = propertiesMap.get(key);
- if (rtrnVal == null) {
- return defaultValue;
- }
- return Integer.valueOf(rtrnVal);
- }
-
- public static Integer getIntProperty(String key) {
- if (key == null) {
- return null;
- }
- String rtrnVal = propertiesMap.get(key);
- if (rtrnVal == null) {
- return null;
- }
- return Integer.valueOf(rtrnVal);
- }
-
- public static Long getLongProperty(String key, long defaultValue) {
- if (key == null) {
- return null;
- }
- String rtrnVal = propertiesMap.get(key);
- if (rtrnVal == null) {
- return defaultValue;
- }
- return Long.valueOf(rtrnVal);
- }
-
- public static Long getLongProperty(String key) {
- if (key == null) {
- return null;
- }
- String rtrnVal = propertiesMap.get(key);
- if (rtrnVal == null) {
- return null;
- }
- return Long.valueOf(rtrnVal);
- }
-
public static boolean getBooleanProperty(String key, boolean defaultValue) {
if (key == null) {
return defaultValue;
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertyMapper.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertyMapper.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertyMapper.java
deleted file mode 100644
index 90e2114..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertyMapper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.common;
-
-import com.google.common.base.Splitter;
-import org.springframework.stereotype.Component;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Component("propertyMapper")
-public class PropertyMapper {
-
- public Map<String, String> map(String property) {
- return this.map(property, ",");
- }
-
- public List<String> list(String property) {
- return this.list(property, ",");
- }
-
- public Map<String, String> solrUiMap(String property) { return this.solrUiMap(property, ","); }
-
- private List<String> list(String property, String splitter) {
- return Splitter.on(splitter).omitEmptyStrings().trimResults().splitToList(property);
- }
-
- private Map<String, String> map(String property, String splitter) {
- return Splitter.on(splitter).omitEmptyStrings().trimResults().withKeyValueSeparator(":").split(property);
- }
-
- private Map<String, String> solrUiMap(String property, String splitter) {
- Map<String, String> result = new HashMap<>();
- Map<String, String> map = this.map(property, splitter);
- for (Map.Entry<String, String> propEntry : map.entrySet()) {
- result.put(propEntry.getKey() + LogSearchConstants.SOLR_SUFFIX, propEntry.getValue());
- result.put(propEntry.getValue() + LogSearchConstants.UI_SUFFIX, propEntry.getKey());
- }
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthConfig.java
deleted file mode 100644
index 46d07bd..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthConfig.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.conf;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class AuthConfig {
-
- @Value("${logsearch.auth.file.enable:true}")
- boolean authFileEnabled;
- @Value("${logsearch.auth.ldap.enable:false}")
- boolean authLdapEnabled;
- @Value("${logsearch.auth.simple.enable:false}")
- boolean authSimpleEnabled;
- @Value("${logsearch.auth.external_auth.enable:false}")
- boolean authExternalEnabled;
- @Value("${logsearch.auth.external_auth.host_url:'http://ip:port'}")
- private String externalAuthHostUrl;
- @Value("${logsearch.auth.external_auth.login_url:/api/v1/users/$USERNAME/privileges?fields=*}")
- private String externalAuthLoginUrl;
- @Value("${logsearch.login.credentials.file:user_pass.json}")
- private String credentialsFile;
-
- public boolean isAuthFileEnabled() {
- return authFileEnabled;
- }
-
- public void setAuthFileEnabled(boolean authFileEnabled) {
- this.authFileEnabled = authFileEnabled;
- }
-
- public boolean isAuthLdapEnabled() {
- return authLdapEnabled;
- }
-
- public void setAuthLdapEnabled(boolean authLdapEnabled) {
- this.authLdapEnabled = authLdapEnabled;
- }
-
- public boolean isAuthSimpleEnabled() {
- return authSimpleEnabled;
- }
-
- public void setAuthSimpleEnabled(boolean authSimpleEnabled) {
- this.authSimpleEnabled = authSimpleEnabled;
- }
-
- public String getCredentialsFile() {
- return credentialsFile;
- }
-
- public void setCredentialsFile(String credentialsFile) {
- this.credentialsFile = credentialsFile;
- }
-
- public String getExternalAuthHostUrl() {
- return externalAuthHostUrl;
- }
-
- public void setExternalAuthHostUrl(String externalAuthHostUrl) {
- this.externalAuthHostUrl = externalAuthHostUrl;
- }
-
- public String getExternalAuthLoginUrl() {
- return externalAuthLoginUrl;
- }
-
- public void setExternalAuthLoginUrl(String externalAuthLoginUrl) {
- this.externalAuthLoginUrl = externalAuthLoginUrl;
- }
-
- public boolean isAuthExternalEnabled() {
- return authExternalEnabled;
- }
-
- public void setAuthExternalEnabled(boolean authExternalEnabled) {
- this.authExternalEnabled = authExternalEnabled;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthPropsConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthPropsConfig.java
new file mode 100644
index 0000000..11b1cda
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthPropsConfig.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.conf;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class AuthPropsConfig {
+
+ @Value("${logsearch.auth.file.enable:true}")
+ boolean authFileEnabled;
+ @Value("${logsearch.auth.ldap.enable:false}")
+ boolean authLdapEnabled;
+ @Value("${logsearch.auth.simple.enable:false}")
+ boolean authSimpleEnabled;
+ @Value("${logsearch.auth.external_auth.enable:false}")
+ boolean authExternalEnabled;
+ @Value("${logsearch.auth.external_auth.host_url:'http://ip:port'}")
+ private String externalAuthHostUrl;
+ @Value("${logsearch.auth.external_auth.login_url:/api/v1/users/$USERNAME/privileges?fields=*}")
+ private String externalAuthLoginUrl;
+ @Value("${logsearch.login.credentials.file:user_pass.json}")
+ private String credentialsFile;
+
+ public boolean isAuthFileEnabled() {
+ return authFileEnabled;
+ }
+
+ public void setAuthFileEnabled(boolean authFileEnabled) {
+ this.authFileEnabled = authFileEnabled;
+ }
+
+ public boolean isAuthLdapEnabled() {
+ return authLdapEnabled;
+ }
+
+ public void setAuthLdapEnabled(boolean authLdapEnabled) {
+ this.authLdapEnabled = authLdapEnabled;
+ }
+
+ public boolean isAuthSimpleEnabled() {
+ return authSimpleEnabled;
+ }
+
+ public void setAuthSimpleEnabled(boolean authSimpleEnabled) {
+ this.authSimpleEnabled = authSimpleEnabled;
+ }
+
+ public String getCredentialsFile() {
+ return credentialsFile;
+ }
+
+ public void setCredentialsFile(String credentialsFile) {
+ this.credentialsFile = credentialsFile;
+ }
+
+ public String getExternalAuthHostUrl() {
+ return externalAuthHostUrl;
+ }
+
+ public void setExternalAuthHostUrl(String externalAuthHostUrl) {
+ this.externalAuthHostUrl = externalAuthHostUrl;
+ }
+
+ public String getExternalAuthLoginUrl() {
+ return externalAuthLoginUrl;
+ }
+
+ public void setExternalAuthLoginUrl(String externalAuthLoginUrl) {
+ this.externalAuthLoginUrl = externalAuthLoginUrl;
+ }
+
+ public boolean isAuthExternalEnabled() {
+ return authExternalEnabled;
+ }
+
+ public void setAuthExternalEnabled(boolean authExternalEnabled) {
+ this.authExternalEnabled = authExternalEnabled;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogConfig.java
deleted file mode 100644
index ae4dca9..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogConfig.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.conf;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.List;
-import java.util.Map;
-
-@Configuration
-public class SolrAuditLogConfig implements SolrConfig, SolrColumnConfig {
-
- @Value("${logsearch.solr.audit.logs.url:}")
- private String solrUrl;
-
- @Value("${logsearch.solr.audit.logs.zk_connect_string:}")
- private String zkConnectString;
-
- @Value("${logsearch.solr.collection.audit.logs:audit_logs}")
- private String collection;
-
- @Value("${logsearch.ranger.audit.logs.collection.name:}")
- private String rangerCollection;
-
- @Value("${logsearch.solr.audit.logs.config.name:audit_logs}")
- private String configName;
-
- @Value("${logsearch.solr.audit.logs.alias.name:audit_logs_alias}")
- private String aliasNameIn;
-
- @Value("${logsearch.audit.logs.split.interval.mins:none}")
- private String splitInterval;
-
- @Value("${logsearch.collection.audit.logs.numshards:1}")
- private Integer numberOfShards;
-
- @Value("${logsearch.collection.audit.logs.replication.factor:1}")
- private Integer replicationFactor;
-
- @Value("#{propertyMapper.map('${logsearch.solr.audit.logs.column.mapping}')}")
- private Map<String, String> columnMapping;
-
- @Value("#{propertyMapper.list('${logsearch.solr.audit.logs.exclude.columnlist}')}")
- private List<String> excludeColumnList;
-
- @Value("#{propertyMapper.solrUiMap('${logsearch.solr.audit.logs.column.mapping}')}")
- private Map<String, String> solrAndUiColumns;
-
- @Override
- public String getSolrUrl() {
- return solrUrl;
- }
-
- @Override
- public void setSolrUrl(String solrUrl) {
- this.solrUrl = solrUrl;
- }
-
- @Override
- public String getCollection() {
- return collection;
- }
-
- @Override
- public void setCollection(String collection) {
- this.collection = collection;
- }
-
- @Override
- public String getZkConnectString() {
- return zkConnectString;
- }
-
- @Override
- public void setZkConnectString(String zkConnectString) {
- this.zkConnectString = zkConnectString;
- }
-
- @Override
- public String getConfigName() {
- return configName;
- }
-
- @Override
- public void setConfigName(String configName) {
- this.configName = configName;
- }
-
- @Override
- public Integer getNumberOfShards() {
- return numberOfShards;
- }
-
- @Override
- public void setNumberOfShards(Integer numberOfShards) {
- this.numberOfShards = numberOfShards;
- }
-
- @Override
- public Integer getReplicationFactor() {
- return replicationFactor;
- }
-
- @Override
- public void setReplicationFactor(Integer replicationFactor) {
- this.replicationFactor = replicationFactor;
- }
-
- @Override
- public String getSplitInterval() {
- return splitInterval;
- }
-
- @Override
- public void setSplitInterval(String splitInterval) {
- this.splitInterval = splitInterval;
- }
-
- @Override
- public List<String> getExcludeColumnList() {
- return excludeColumnList;
- }
-
- @Override
- public void setExcludeColumnList(List<String> excludeColumnList) {
- this.excludeColumnList = excludeColumnList;
- }
-
- @Override
- public Map<String, String> getColumnMapping() {
- return columnMapping;
- }
-
- @Override
- public void setColumnMapping(Map<String, String> columnMappings) {
- this.columnMapping = columnMappings;
- }
-
- @Override
- public Map<String, String> getSolrAndUiColumns() {
- return solrAndUiColumns;
- }
-
- @Override
- public void setSolrAndUiColumns(Map<String, String> solrAndUiColumns) {
- this.solrAndUiColumns = solrAndUiColumns;
- }
-
- public String getRangerCollection() {
- return rangerCollection;
- }
-
- public void setRangerCollection(String rangerCollection) {
- this.rangerCollection = rangerCollection;
- }
-
- public String getAliasNameIn() {
- return aliasNameIn;
- }
-
- public void setAliasNameIn(String aliasNameIn) {
- this.aliasNameIn = aliasNameIn;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogPropsConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogPropsConfig.java
new file mode 100644
index 0000000..d270b13
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogPropsConfig.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.conf;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.List;
+import java.util.Map;
+
+@Configuration
+public class SolrAuditLogPropsConfig implements SolrPropsConfig {
+
+ @Value("${logsearch.solr.audit.logs.url:}")
+ private String solrUrl;
+
+ @Value("${logsearch.solr.audit.logs.zk_connect_string:}")
+ private String zkConnectString;
+
+ @Value("${logsearch.solr.collection.audit.logs:audit_logs}")
+ private String collection;
+
+ @Value("${logsearch.ranger.audit.logs.collection.name:}")
+ private String rangerCollection;
+
+ @Value("${logsearch.solr.audit.logs.config.name:audit_logs}")
+ private String configName;
+
+ @Value("${logsearch.solr.audit.logs.alias.name:audit_logs_alias}")
+ private String aliasNameIn;
+
+ @Value("${logsearch.audit.logs.split.interval.mins:none}")
+ private String splitInterval;
+
+ @Value("${logsearch.collection.audit.logs.numshards:1}")
+ private Integer numberOfShards;
+
+ @Value("${logsearch.collection.audit.logs.replication.factor:1}")
+ private Integer replicationFactor;
+
+ @Override
+ public String getSolrUrl() {
+ return solrUrl;
+ }
+
+ @Override
+ public void setSolrUrl(String solrUrl) {
+ this.solrUrl = solrUrl;
+ }
+
+ @Override
+ public String getCollection() {
+ return collection;
+ }
+
+ @Override
+ public void setCollection(String collection) {
+ this.collection = collection;
+ }
+
+ @Override
+ public String getZkConnectString() {
+ return zkConnectString;
+ }
+
+ @Override
+ public void setZkConnectString(String zkConnectString) {
+ this.zkConnectString = zkConnectString;
+ }
+
+ @Override
+ public String getConfigName() {
+ return configName;
+ }
+
+ @Override
+ public void setConfigName(String configName) {
+ this.configName = configName;
+ }
+
+ @Override
+ public Integer getNumberOfShards() {
+ return numberOfShards;
+ }
+
+ @Override
+ public void setNumberOfShards(Integer numberOfShards) {
+ this.numberOfShards = numberOfShards;
+ }
+
+ @Override
+ public Integer getReplicationFactor() {
+ return replicationFactor;
+ }
+
+ @Override
+ public void setReplicationFactor(Integer replicationFactor) {
+ this.replicationFactor = replicationFactor;
+ }
+
+ @Override
+ public String getSplitInterval() {
+ return splitInterval;
+ }
+
+ @Override
+ public void setSplitInterval(String splitInterval) {
+ this.splitInterval = splitInterval;
+ }
+
+ public String getRangerCollection() {
+ return rangerCollection;
+ }
+
+ public void setRangerCollection(String rangerCollection) {
+ this.rangerCollection = rangerCollection;
+ }
+
+ public String getAliasNameIn() {
+ return aliasNameIn;
+ }
+
+ public void setAliasNameIn(String aliasNameIn) {
+ this.aliasNameIn = aliasNameIn;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrColumnConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrColumnConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrColumnConfig.java
deleted file mode 100644
index a12b2ce..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrColumnConfig.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.conf;
-
-import java.util.List;
-import java.util.Map;
-
-public interface SolrColumnConfig {
- Map<String, String> getColumnMapping();
-
- void setColumnMapping(Map<String, String> columnMapping);
-
- List<String> getExcludeColumnList();
-
- void setExcludeColumnList(List<String> excludeColumnList);
-
- Map<String, String> getSolrAndUiColumns();
-
- void setSolrAndUiColumns(Map<String, String> solrAndUiColumns);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
index cfbe097..7508fb1 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
@@ -18,33 +18,87 @@
*/
package org.apache.ambari.logsearch.conf;
-public interface SolrConfig {
- String getSolrUrl();
+import org.apache.ambari.logsearch.solr.AmbariSolrCloudClient;
+import org.apache.ambari.logsearch.solr.AmbariSolrCloudClientBuilder;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.impl.HttpClientUtil;
+import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.DependsOn;
+import org.springframework.data.solr.core.SolrTemplate;
+import org.springframework.data.solr.repository.config.EnableSolrRepositories;
- void setSolrUrl(String solrUrl);
+import javax.inject.Inject;
- String getZkConnectString();
+@Configuration
+@EnableSolrRepositories
+public class SolrConfig {
- void setZkConnectString(String zkConnectString);
+ private static final Logger LOG = LoggerFactory.getLogger(SolrConfig.class);
- String getCollection();
+ @Inject
+ private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
- void setCollection(String collection);
+ @Inject
+ private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
- String getConfigName();
+ @Inject
+ private SolrUserPropsConfig solrUserConfigPropsConfig;
- void setConfigName(String configName);
+ @Inject
+ private SolrKerberosConfig solrKerberosConfig;
- Integer getNumberOfShards();
+ @Bean(name = "serviceSolrTemplate")
+ public SolrTemplate serviceSolrTemplate() {
+ setupSecurity();
+ return new SolrTemplate(createClient(
+ solrServiceLogPropsConfig.getSolrUrl(),
+ solrServiceLogPropsConfig.getZkConnectString(),
+ solrServiceLogPropsConfig.getCollection()));
+ }
- void setNumberOfShards(Integer numberOfShards);
+ @Bean(name = "auditSolrTemplate")
+ @DependsOn("serviceSolrTemplate")
+ public SolrTemplate auditSolrTemplate() {
+ return new SolrTemplate(createClient(
+ solrAuditLogPropsConfig.getSolrUrl(),
+ solrAuditLogPropsConfig.getZkConnectString(),
+ solrAuditLogPropsConfig.getCollection()));
+ }
- Integer getReplicationFactor();
+ @Bean(name = "userConfigSolrTemplate")
+ @DependsOn("serviceSolrTemplate")
+ public SolrTemplate userConfigSolrTemplate() {
+ return new SolrTemplate(createClient(
+ solrUserConfigPropsConfig.getSolrUrl(),
+ solrUserConfigPropsConfig.getZkConnectString(),
+ solrUserConfigPropsConfig.getCollection()));
+ }
- void setReplicationFactor(Integer replicationFactor);
-
- String getSplitInterval();
-
- void setSplitInterval(String splitInterval);
+ private CloudSolrClient createClient(String solrUrl, String zookeeperConnectString, String defaultCollection) {
+ if (StringUtils.isNotEmpty(zookeeperConnectString)) {
+ CloudSolrClient cloudSolrClient = new CloudSolrClient(zookeeperConnectString);
+ cloudSolrClient.setDefaultCollection(defaultCollection);
+ return cloudSolrClient;
+ } else if (StringUtils.isNotEmpty(solrUrl)) {
+ throw new UnsupportedOperationException("Currently only cloud mode is supported. Set zookeeper connect string.");
+ }
+ throw new IllegalStateException(
+ "Solr url or zookeeper connection string is missing. collection: " + defaultCollection);
+ }
+ private void setupSecurity() {
+ String jaasFile = solrKerberosConfig.getJaasFile();
+ boolean securityEnabled = solrKerberosConfig.isEnabled();
+ if (securityEnabled) {
+ System.setProperty("java.security.auth.login.config", jaasFile);
+ HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
+ LOG.info("setupSecurity() called for kerberos configuration, jaas file: " + jaasFile);
+ }
+ }
}
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionConfig.java
deleted file mode 100644
index b3dceea..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionConfig.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.conf;
-
-import org.springframework.beans.factory.annotation.Value;
-
-public abstract class SolrConnectionConfig implements SolrConfig {
- @Value("${logsearch.solr.url:}")
- private String solrUrl;
-
- @Value("${logsearch.solr.zk_connect_string:}")
- private String zkConnectString;
-
- @Override
- public String getSolrUrl() {
- return solrUrl;
- }
-
- @Override
- public void setSolrUrl(String solrUrl) {
- this.solrUrl = solrUrl;
- }
-
- @Override
- public String getZkConnectString() {
- return zkConnectString;
- }
-
- @Override
- public void setZkConnectString(String zkConnectString) {
- this.zkConnectString = zkConnectString;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionPropsConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionPropsConfig.java
new file mode 100644
index 0000000..82dd7df
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionPropsConfig.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.conf;
+
+import org.springframework.beans.factory.annotation.Value;
+
+public abstract class SolrConnectionPropsConfig implements SolrPropsConfig {
+ @Value("${logsearch.solr.url:}")
+ private String solrUrl;
+
+ @Value("${logsearch.solr.zk_connect_string:}")
+ private String zkConnectString;
+
+ @Override
+ public String getSolrUrl() {
+ return solrUrl;
+ }
+
+ @Override
+ public void setSolrUrl(String solrUrl) {
+ this.solrUrl = solrUrl;
+ }
+
+ @Override
+ public String getZkConnectString() {
+ return zkConnectString;
+ }
+
+ @Override
+ public void setZkConnectString(String zkConnectString) {
+ this.zkConnectString = zkConnectString;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrPropsConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrPropsConfig.java
new file mode 100644
index 0000000..78012b0
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrPropsConfig.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.conf;
+
+public interface SolrPropsConfig {
+ String getSolrUrl();
+
+ void setSolrUrl(String solrUrl);
+
+ String getZkConnectString();
+
+ void setZkConnectString(String zkConnectString);
+
+ String getCollection();
+
+ void setCollection(String collection);
+
+ String getConfigName();
+
+ void setConfigName(String configName);
+
+ Integer getNumberOfShards();
+
+ void setNumberOfShards(Integer numberOfShards);
+
+ Integer getReplicationFactor();
+
+ void setReplicationFactor(Integer replicationFactor);
+
+ String getSplitInterval();
+
+ void setSplitInterval(String splitInterval);
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogConfig.java
deleted file mode 100644
index e768402..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogConfig.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.conf;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.List;
-import java.util.Map;
-
-@Configuration
-public class SolrServiceLogConfig extends SolrConnectionConfig implements SolrColumnConfig {
-
- @Value("${logsearch.solr.collection.service.logs:hadoop_logs}")
- private String collection;
-
- @Value("${logsearch.service.logs.split.interval.mins:none}")
- private String splitInterval;
-
- @Value("${logsearch.solr.service.logs.config.name:hadoop_logs}")
- private String configName;
-
- @Value("${logsearch.collection.service.logs.numshards:1}")
- private Integer numberOfShards;
-
- @Value("${logsearch.collection.service.logs.replication.factor:1}")
- private Integer replicationFactor;
-
- @Value("#{propertyMapper.list('${logsearch.service.logs.fields}')}")
- private List<String> fields;
-
- @Value("#{propertyMapper.map('${logsearch.solr.audit.logs.column.mapping}')}")
- private Map<String, String> columnMapping;
-
- @Value("#{propertyMapper.list('${logsearch.solr.audit.logs.exclude.columnlist}')}")
- private List<String> excludeColumnList;
-
- @Value("#{propertyMapper.solrUiMap('${logsearch.solr.audit.logs.column.mapping}}')}")
- private Map<String, String> solrAndUiColumns;
-
- @Override
- public String getCollection() {
- return collection;
- }
-
- @Override
- public void setCollection(String collection) {
- this.collection = collection;
- }
-
- @Override
- public String getSplitInterval() {
- return splitInterval;
- }
-
- @Override
- public void setSplitInterval(String splitInterval) {
- this.splitInterval = splitInterval;
- }
-
- @Override
- public String getConfigName() {
- return configName;
- }
-
- @Override
- public void setConfigName(String configName) {
- this.configName = configName;
- }
-
- @Override
- public Integer getNumberOfShards() {
- return numberOfShards;
- }
-
- @Override
- public void setNumberOfShards(Integer numberOfShards) {
- this.numberOfShards = numberOfShards;
- }
-
- @Override
- public Integer getReplicationFactor() {
- return replicationFactor;
- }
-
- @Override
- public void setReplicationFactor(Integer replicationFactor) {
- this.replicationFactor = replicationFactor;
- }
-
- @Override
- public Map<String, String> getColumnMapping() {
- return columnMapping;
- }
-
- @Override
- public void setColumnMapping(Map<String, String> columnMapping) {
- this.columnMapping = columnMapping;
- }
-
- @Override
- public List<String> getExcludeColumnList() {
- return excludeColumnList;
- }
-
- @Override
- public void setExcludeColumnList(List<String> excludeColumnList) {
- this.excludeColumnList = excludeColumnList;
- }
-
- @Override
- public Map<String, String> getSolrAndUiColumns() {
- return solrAndUiColumns;
- }
-
- @Override
- public void setSolrAndUiColumns(Map<String, String> solrAndUiColumns) {
- this.solrAndUiColumns = solrAndUiColumns;
- }
-
- public List<String> getFields() {
- return fields;
- }
-
- public void setFields(List<String> fields) {
- this.fields = fields;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
new file mode 100644
index 0000000..81935d4
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.conf;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.List;
+import java.util.Map;
+
+@Configuration
+public class SolrServiceLogPropsConfig extends SolrConnectionPropsConfig {
+
+ @Value("${logsearch.solr.collection.service.logs:hadoop_logs}")
+ private String collection;
+
+ @Value("${logsearch.service.logs.split.interval.mins:none}")
+ private String splitInterval;
+
+ @Value("${logsearch.solr.service.logs.config.name:hadoop_logs}")
+ private String configName;
+
+ @Value("${logsearch.collection.service.logs.numshards:1}")
+ private Integer numberOfShards;
+
+ @Value("${logsearch.collection.service.logs.replication.factor:1}")
+ private Integer replicationFactor;
+
+ @Override
+ public String getCollection() {
+ return collection;
+ }
+
+ @Override
+ public void setCollection(String collection) {
+ this.collection = collection;
+ }
+
+ @Override
+ public String getSplitInterval() {
+ return splitInterval;
+ }
+
+ @Override
+ public void setSplitInterval(String splitInterval) {
+ this.splitInterval = splitInterval;
+ }
+
+ @Override
+ public String getConfigName() {
+ return configName;
+ }
+
+ @Override
+ public void setConfigName(String configName) {
+ this.configName = configName;
+ }
+
+ @Override
+ public Integer getNumberOfShards() {
+ return numberOfShards;
+ }
+
+ @Override
+ public void setNumberOfShards(Integer numberOfShards) {
+ this.numberOfShards = numberOfShards;
+ }
+
+ @Override
+ public Integer getReplicationFactor() {
+ return replicationFactor;
+ }
+
+ @Override
+ public void setReplicationFactor(Integer replicationFactor) {
+ this.replicationFactor = replicationFactor;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserConfig.java
deleted file mode 100644
index 8ae630a..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserConfig.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.conf;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.List;
-
-@Configuration
-public class SolrUserConfig extends SolrConnectionConfig {
-
- @Value("${logsearch.solr.collection.history:history}")
- private String collection;
-
- @Value("${logsearch.history.split.interval.mins:none}")
- private String splitInterval;
-
- @Value("${logsearch.solr.history.config.name:history}")
- private String configName;
-
- @Value("${logsearch.collection.history.numshards:1}")
- private Integer numberOfShards;
-
- @Value("${logsearch.collection.history.replication.factor:2}")
- private Integer replicationFactor;
-
- @Value("#{'${logsearch.logfeeder.include.default.level:FATAL,ERROR,WARN,INFO,DEBUG,TRACE,UNKNOWN}'.split(',')}")
- private List<String> logLevels;
-
- @Override
- public String getCollection() {
- return collection;
- }
-
- @Override
- public void setCollection(String collection) {
- this.collection = collection;
- }
-
- @Override
- public String getSplitInterval() {
- return splitInterval;
- }
-
- @Override
- public void setSplitInterval(String splitInterval) {
- this.splitInterval = splitInterval;
- }
-
- @Override
- public String getConfigName() {
- return configName;
- }
-
- @Override
- public void setConfigName(String configName) {
- this.configName = configName;
- }
-
- @Override
- public Integer getNumberOfShards() {
- return numberOfShards;
- }
-
- @Override
- public void setNumberOfShards(Integer numberOfShards) {
- this.numberOfShards = numberOfShards;
- }
-
- @Override
- public Integer getReplicationFactor() {
- return replicationFactor;
- }
-
- @Override
- public void setReplicationFactor(Integer replicationFactor) {
- this.replicationFactor = replicationFactor;
- }
-
- public List<String> getLogLevels() {
- return logLevels;
- }
-
- public void setLogLevels(List<String> logLevels) {
- this.logLevels = logLevels;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java
new file mode 100644
index 0000000..38366d5
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.conf;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.List;
+
+@Configuration
+public class SolrUserPropsConfig extends SolrConnectionPropsConfig {
+
+ @Value("${logsearch.solr.collection.history:history}")
+ private String collection;
+
+ @Value("${logsearch.history.split.interval.mins:none}")
+ private String splitInterval;
+
+ @Value("${logsearch.solr.history.config.name:history}")
+ private String configName;
+
+ @Value("${logsearch.collection.history.numshards:1}")
+ private Integer numberOfShards;
+
+ @Value("${logsearch.collection.history.replication.factor:2}")
+ private Integer replicationFactor;
+
+ @Value("#{'${logsearch.logfeeder.include.default.level:FATAL,ERROR,WARN,INFO,DEBUG,TRACE,UNKNOWN}'.split(',')}")
+ private List<String> logLevels;
+
+ @Override
+ public String getCollection() {
+ return collection;
+ }
+
+ @Override
+ public void setCollection(String collection) {
+ this.collection = collection;
+ }
+
+ @Override
+ public String getSplitInterval() {
+ return splitInterval;
+ }
+
+ @Override
+ public void setSplitInterval(String splitInterval) {
+ this.splitInterval = splitInterval;
+ }
+
+ @Override
+ public String getConfigName() {
+ return configName;
+ }
+
+ @Override
+ public void setConfigName(String configName) {
+ this.configName = configName;
+ }
+
+ @Override
+ public Integer getNumberOfShards() {
+ return numberOfShards;
+ }
+
+ @Override
+ public void setNumberOfShards(Integer numberOfShards) {
+ this.numberOfShards = numberOfShards;
+ }
+
+ @Override
+ public Integer getReplicationFactor() {
+ return replicationFactor;
+ }
+
+ @Override
+ public void setReplicationFactor(Integer replicationFactor) {
+ this.replicationFactor = replicationFactor;
+ }
+
+ public List<String> getLogLevels() {
+ return logLevels;
+ }
+
+ public void setLogLevels(List<String> logLevels) {
+ this.logLevels = logLevels;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
index 4f5e734..8d6a4da 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
@@ -19,58 +19,65 @@
package org.apache.ambari.logsearch.dao;
-import java.util.Arrays;
-import java.util.Collection;
-
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import org.apache.ambari.logsearch.common.PropertiesHelper;
-import org.apache.ambari.logsearch.conf.SolrAuditLogConfig;
+import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.stereotype.Component;
@Component
public class AuditSolrDao extends SolrDaoBase {
- private static final Logger logger = Logger.getLogger(AuditSolrDao.class);
+ private static final Logger LOG = Logger.getLogger(AuditSolrDao.class);
+
+ @Inject
+ private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
+
+ @Inject
+ @Qualifier("auditSolrTemplate")
+ private SolrTemplate auditSolrTemplate;
@Inject
- private SolrAuditLogConfig solrAuditLogConfig;
+ private SolrAliasDao solrAliasDao;
+
+ @Inject
+ private SolrCollectionDao solrCollectionDao;
+
+ @Inject
+ private SolrSchemaFieldDao solrSchemaFieldDao;
public AuditSolrDao() {
super(LogType.AUDIT);
}
+ @Override
+ public CloudSolrClient getSolrClient() {
+ return (CloudSolrClient) auditSolrTemplate.getSolrClient();
+ }
+
@PostConstruct
public void postConstructor() {
- String solrUrl = solrAuditLogConfig.getSolrUrl();
- String zkConnectString = solrAuditLogConfig.getZkConnectString();
- String collection = solrAuditLogConfig.getCollection();
- String aliasNameIn = solrAuditLogConfig.getAliasNameIn();
- String rangerAuditCollection = solrAuditLogConfig.getRangerCollection();
- String splitInterval = solrAuditLogConfig.getSplitInterval();
- String configName = solrAuditLogConfig.getConfigName();
- int numberOfShards = solrAuditLogConfig.getNumberOfShards();
- int replicationFactor = solrAuditLogConfig.getReplicationFactor();
+ String aliasNameIn = solrAuditLogPropsConfig.getAliasNameIn();
+ String rangerAuditCollection = solrAuditLogPropsConfig.getRangerCollection();
try {
- connectToSolr(solrUrl, zkConnectString, collection);
-
+ solrCollectionDao.checkSolrStatus(getSolrClient());
boolean createAlias = (aliasNameIn != null && !StringUtils.isBlank(rangerAuditCollection));
- boolean needToPopulateSchemaField = !createAlias;
-
- setupCollections(splitInterval, configName, numberOfShards, replicationFactor, needToPopulateSchemaField);
-
+ solrCollectionDao.setupCollections(getSolrClient(), solrAuditLogPropsConfig);
if (createAlias) {
- Collection<String> collectionsIn = Arrays.asList(collection, rangerAuditCollection.trim());
- setupAlias(aliasNameIn, collectionsIn);
+ solrAliasDao.setupAlias(solrSchemaFieldDao, getSolrClient(), solrAuditLogPropsConfig, this);
+ } else {
+ solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrAuditLogPropsConfig, this);
}
} catch (Exception e) {
- logger.error("Error while connecting to Solr for audit logs : solrUrl=" + solrUrl + ", zkConnectString=" +
- zkConnectString + ", collection=" + collection, e);
+ LOG.error("Error while connecting to Solr for audit logs : solrUrl=" + solrAuditLogPropsConfig.getSolrUrl() + ", zkConnectString=" +
+ solrAuditLogPropsConfig.getZkConnectString() + ", collection=" + solrAuditLogPropsConfig.getCollection(), e);
}
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
index e338b7c..a6f5acf 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
@@ -22,41 +22,52 @@ package org.apache.ambari.logsearch.dao;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import org.apache.ambari.logsearch.common.PropertiesHelper;
-import org.apache.ambari.logsearch.conf.SolrServiceLogConfig;
+import org.apache.ambari.logsearch.conf.SolrServiceLogPropsConfig;
import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.stereotype.Component;
@Component
public class ServiceLogsSolrDao extends SolrDaoBase {
- private static final Logger logger = Logger.getLogger(ServiceLogsSolrDao.class);
+ private static final Logger LOG = Logger.getLogger(ServiceLogsSolrDao.class);
@Inject
- private SolrServiceLogConfig solrServiceLogConfig;
-
+ private SolrCollectionDao solrCollectionDao;
+
+ @Inject
+ private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
+
+ @Inject
+ @Qualifier("serviceSolrTemplate")
+ private SolrTemplate serviceSolrTemplate;
+
+ @Inject
+ private SolrSchemaFieldDao solrSchemaFieldDao;
+
public ServiceLogsSolrDao() {
super(LogType.SERVICE);
}
+ @Override
+ public CloudSolrClient getSolrClient() {
+ return (CloudSolrClient) serviceSolrTemplate.getSolrClient();
+ }
+
@PostConstruct
public void postConstructor() {
- logger.info("postConstructor() called.");
- String solrUrl = solrServiceLogConfig.getSolrUrl();
- String zkConnectString = solrServiceLogConfig.getZkConnectString();
- String collection = solrServiceLogConfig.getCollection();
- String splitInterval = solrServiceLogConfig.getSplitInterval();
- String configName = solrServiceLogConfig.getConfigName();
- int numberOfShards = solrServiceLogConfig.getNumberOfShards();
- int replicationFactor = solrServiceLogConfig.getReplicationFactor();
-
+ LOG.info("postConstructor() called.");
try {
- connectToSolr(solrUrl, zkConnectString, collection);
- setupCollections(splitInterval, configName, numberOfShards, replicationFactor, true);
+ solrCollectionDao.checkSolrStatus(getSolrClient());
+ solrCollectionDao.setupCollections(getSolrClient(), solrServiceLogPropsConfig);
+ solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrServiceLogPropsConfig, this);
} catch (Exception e) {
- logger.error("error while connecting to Solr for service logs : solrUrl=" + solrUrl + ", zkConnectString=" +
- zkConnectString + ", collection=" + collection, e);
+ LOG.error("error while connecting to Solr for service logs : solrUrl=" + solrServiceLogPropsConfig.getSolrUrl()
+ + ", zkConnectString=" + solrServiceLogPropsConfig.getZkConnectString()
+ + ", collection=" + solrServiceLogPropsConfig.getCollection(), e);
}
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
new file mode 100644
index 0000000..81471d3
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.dao;
+
+import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+@Component
+public class SolrAliasDao {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SolrAliasDao.class);
+
+ private static final int ALIAS_SETUP_RETRY_SECOND = 30*60;
+
+ @Inject
+ private SolrCollectionDao solrCollectionDao;
+
+ protected void setupAlias(final SolrSchemaFieldDao solrSchemaFieldDao, final CloudSolrClient solrClient,
+ final SolrAuditLogPropsConfig solrPropsConfig, final SolrDaoBase solrDaoBase) throws Exception {
+ final Collection<String> collectionListIn = Arrays.asList(solrPropsConfig.getCollection(), solrPropsConfig.getRangerCollection().trim());
+
+ if (solrPropsConfig.getAliasNameIn() == null || collectionListIn.size() == 0 || solrClient == null) {
+ LOG.info("Will not create alias " + solrPropsConfig.getAliasNameIn() + " for " +
+ collectionListIn.toString() + ", solrCloudClient=" + solrClient);
+ return;
+ }
+
+ LOG.info("setupAlias " + solrPropsConfig.getAliasNameIn() + " for " + collectionListIn.toString());
+ // Start a background thread to do setup
+ Thread setupThread = new Thread("setup_alias_" + solrPropsConfig.getAliasNameIn()) {
+ @Override
+ public void run() {
+ LOG.info("Started monitoring thread to check availability of Solr server. alias=" + solrPropsConfig.getAliasNameIn() +
+ ", collections=" + collectionListIn.toString());
+ int retryCount = 0;
+ while (true) {
+ try {
+ int count = createAlias(solrClient, solrPropsConfig.getAliasNameIn(), collectionListIn);
+ if (count > 0) {
+ solrClient.setDefaultCollection(solrPropsConfig.getAliasNameIn());
+ if (count == collectionListIn.size()) {
+ LOG.info("Setup for alias " + solrPropsConfig.getAliasNameIn() + " is successful. Exiting setup retry thread. " +
+ "Collections=" + collectionListIn);
+ solrSchemaFieldDao.populateSchemaFields(solrClient, solrPropsConfig, solrDaoBase);
+ break;
+ }
+ } else {
+ LOG.warn("Not able to create alias=" + solrPropsConfig.getAliasNameIn() + ", retryCount=" + retryCount);
+ }
+ } catch (Exception e) {
+ LOG.error("Error setting up alias=" + solrPropsConfig.getAliasNameIn(), e);
+ }
+ try {
+ Thread.sleep(ALIAS_SETUP_RETRY_SECOND * 1000);
+ } catch (InterruptedException sleepInterrupted) {
+ LOG.info("Sleep interrupted while setting up alias " + solrPropsConfig.getAliasNameIn());
+ break;
+ }
+ retryCount++;
+ }
+ }
+ };
+ setupThread.setDaemon(true);
+ setupThread.start();
+ }
+
+ private int createAlias(final CloudSolrClient solrClient, String aliasNameIn, Collection<String> collectionListIn)
+ throws SolrServerException, IOException {
+ List<String> collectionToAdd = solrCollectionDao.getCollections(solrClient);
+ collectionToAdd.retainAll(collectionListIn);
+
+ String collectionsCSV = null;
+ if (!collectionToAdd.isEmpty()) {
+ collectionsCSV = StringUtils.join(collectionToAdd, ',');
+ CollectionAdminRequest.CreateAlias aliasCreateRequest = new CollectionAdminRequest.CreateAlias();
+ aliasCreateRequest.setAliasName(aliasNameIn);
+ aliasCreateRequest.setAliasedCollections(collectionsCSV);
+ CollectionAdminResponse createResponse = aliasCreateRequest.process(solrClient);
+ if (createResponse.getStatus() != 0) {
+ LOG.error("Error creating alias. alias=" + aliasNameIn + ", collectionList=" + collectionsCSV
+ + ", response=" + createResponse);
+ return 0;
+ }
+ }
+ if ( collectionToAdd.size() == collectionListIn.size()) {
+ LOG.info("Created alias for all collections. alias=" + aliasNameIn + ", collectionsCSV=" + collectionsCSV);
+ } else {
+ LOG.info("Created alias for " + collectionToAdd.size() + " out of " + collectionListIn.size() + " collections. " +
+ "alias=" + aliasNameIn + ", collectionsCSV=" + collectionsCSV);
+ }
+ return collectionToAdd.size();
+ }
+}
[2/6] ambari git commit: AMBARI-18310. Refactor logsearch portal code
- part 3 (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/BubbleGraphTableLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/BubbleGraphTableLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/BubbleGraphTableLayoutView.js
index 4fb9b51..988c593 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/BubbleGraphTableLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/BubbleGraphTableLayoutView.js
@@ -57,28 +57,9 @@ define(['require',
/** ui events hash */
events: function() {
-// var that=this,
var events = {};
-// events["mouseenter .logTime"] = function(e){
-// $(e.currentTarget).find("a").removeClass("hidden");
-// };
-// events["mouseleave .logTime"] = function(e){
-// $(e.currentTarget).find("a").addClass("hidden");
-// };
-// events["click .logTime a[data-type='C']"] = 'onNewTabIconClick';
events['click [data-id="refresh-tab"]'] = 'onTabRefresh';
events['change ' + this.ui.viewType] = 'onViewTypeChange';
-// events["mouseenter .logTime"] = function(e){
-// var $el = $(e.currentTarget);
-// $el.append(dropdownMenu);
-// $el.find('.quickMenu li').click(function(e){
-// that.onQuickMenuClick(e);
-// });
-// };
-// events["mouseleave .logTime"] = function(e){
-// var $el = $(e.currentTarget);
-// //$el.find(".quickMenu").remove();
-// };
events['click .quickMenu li'] = 'onQuickMenuClick';
return events;
},
@@ -109,11 +90,7 @@ define(['require',
this.listenTo(this.collection, "backgrid:refresh",function(){
$(".contextMenuBody [data-id='F']").show();
$(".contextMenuBody").hide();
- //this.$("#loaderGraph").hide();
this.$(".loader").hide();
- //this.ui.find.trigger("keyup");
-// if (this.quickHelp)
-// this.initializeContextMenu();
},this);
this.listenTo(this.collection, 'request', function(){
this.$("#loader").show();
@@ -126,23 +103,6 @@ define(['require',
this.fetchAllTogether(value);
this.selectionText="";
});
-// this.listenTo(this.vent,"tree:search",function(value){
-// this.fetchAllTogether(value);
-// });
-// this.listenTo(this.vent,"level:filter",function(value){
-// this.fetchAllTogether(value);
-// });
-// this.listenTo(this.vent,"type:mustNot",function(value){
-// this.fetchAllTogether(value);
-// });
-// this.listenTo(this.vent,"type:mustBe",function(value){
-// this.fetchAllTogether(value);
-// });
-// this.listenTo(this.vent,"logtime:filter",function(value){
-// this.fetchAllTogether(value);
-// });
-// this.listenTo(this.vent,"search:include:exclude",function(value){
-// this.fetchAllTogether(value);
// });
this.listenTo(this.vent,"reinitialize:filter:bubbleTable",function(value){
this.reinitializeBubbleTableFilter(value);
@@ -151,12 +111,6 @@ define(['require',
this.fetchAllTogether(value);
}, this);
this.listenTo(this.vent, "timer:end", function(value) {
- //timer should start only after log table fetch is complete.
-// var arr = Utils.dateUtil.getRelativeDateFromString(this.params.dateRangeLabel);
-// if(_.isArray(arr)){
-// this.params.from = arr[0].toJSON();
-// this.params.to = arr[1].toJSON();
-// }
ViewUtils.setLatestTimeParams(this.params);
this.vent.trigger("tab:refresh",this.params);
var that = this;
@@ -180,30 +134,18 @@ define(['require',
var that = this;
this.fetchTableData((this.params) ? this.params : {q:"*:*"});
this.renderComponentList();
- this.collection.getServiceLogFields({},{
- success : function(data){
- that.serverColumns = data;
- },
- complete : function(){
- that.renderTable();
- }
- });
- //this.renderTable();
- this.renderHostList();
- this.renderTimer();
- if(this.quickHelp){
- this.initializeContextMenu();
- this.bindContextMenuClick();
- }
+ this.renderTable();
+ this.renderHostList();
+ this.renderTimer();
+ if(this.quickHelp){
+ this.initializeContextMenu();
+ this.bindContextMenuClick();
+ }
},
onShow : function(){
//this.fetchGraphData((this.params) ? this.params : {q:"*:*"});
},
onTabRefresh : function(){
-// this.fetchAllTogether({});
-// if(this.RHostList.currentView){
-// this.RHostList.currentView.fetchHosts({});
-// }
ViewUtils.setLatestTimeParams(this.params);
this.vent.trigger("tab:refresh",this.params);
},
@@ -215,8 +157,8 @@ define(['require',
id = $el.data("id");
that.globalVent.trigger("render:tab",{
params:_.extend({},{
- host : host,
- component : component,
+ host_name : host,
+ component_name : component,
sourceLogId: id
},that.graphParams,{treeParams:null}),
globalVent : that.globalVent
@@ -292,16 +234,9 @@ define(['require',
var timeZone = moment().zoneAbbr(),
cols = {},
that = this;
- _.each(this.columns,function(value,col){
- cols[col] = {
- label:value,
- cell: "String",
- sortType: 'toggle',
- editable: false,
- }
- });
var columns = {
logtime : {
+ name: "logtime",
label: "Log Time "+(! _.isEmpty(timeZone) ? "("+timeZone+")":""),
cell: "html",
editable: false,
@@ -319,9 +254,7 @@ define(['require',
if(model.get("type"))
str += "<p style='margin-left:20px'>"+(model.get("level") ? "<label class='label label-"+model.get("level")+"'>"+model.get("level")+"</label>" : "")+
"<strong>"+model.get("type")+"</strong>" +
- "</p><!--a style='width:9%' title='Open logs in new tab' data-type='C' data-host='"+model.get("host")+"' data-node='"+model.get("type")+"' data-id='"+model.get("id")+"' href='javascript:void(0)' class='pull-right hidden'><i class='fa fa-share'></i></a-->";
-// if(model.get("level"))
-// str += "<p style='float:left;'><label class='label label-"+model.get("level")+"'>"+model.get("level")+"</label></p>";
+ "</p>";
str += '<div class="dropdown quickMenu">' +
'<a class="btn btn-success btn-xs btn-quickMenu" data-toggle="dropdown">' +
'<i class="fa fa-ellipsis-v"></i></span></a>' +
@@ -335,38 +268,13 @@ define(['require',
}
})
},
- /*type: {
- label: "Type",
- cell: "String",
- editable: false,
- sortType: 'toggle',
- sortable : false,
- orderable : true,
- displayOrder :2,
- width : 11
- },
- level : {
- label: "Level",
- cell: "html",
- editable: false,
- sortType: 'toggle',
- sortable : true,
- orderable : false,
- width : "6",
- displayOrder :3,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model){
- return "<span class='"+rawValue+"'>"+rawValue+"</span>";
- }
- })
- },*/
log_message : {
+ name: "log_message",
label: "Message",
cell: "html",
editable: false,
sortType: 'toggle',
sortable : false,
- //width : "50",
orderable : true,
displayOrder :4,
className : "logMessage",
@@ -418,15 +326,23 @@ define(['require',
}
};
- _.each(cols,function(c,k){
- if(columns[k] == undefined){
- columns[k] = c;
- }else{
- if(columns[k] && columns[k].label){
- columns[k].label = c.label;
- }
- }
- });
+ _.each(this.columns, function(value){
+ var name = Globals.invertedServiceLogMappings[value];
+ if (columns[name] === undefined) {
+ var columnObj = {
+ name: Globals.invertedServiceLogMappings[value],
+ label:value,
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ };
+ columns[name] = columnObj;
+ } else {
+ if (columns[name] && columns[name].label) {
+ columns[name].label = value;
+ }
+ }
+ });
return this.collection.constructor.getTableCols(columns, this.collection);
},
fetchTableData : function(params){
@@ -461,7 +377,6 @@ define(['require',
},
fetchGraphData : function(params){
var that = this;
- //that.$("#loaderGraph").show();
that.$(".loader").show();
this.graphModel.fetch({
dataType:"json",
@@ -472,7 +387,6 @@ define(['require',
error : function(){
},
complete : function(){
- //that.$("#loaderGraph").hide();
that.$(".loader").hide();
}
});
@@ -512,14 +426,6 @@ define(['require',
},
initializeContextMenu : function(){
var that = this;
-// $('body').on("mouseup",function(e){
-// console.log(e);
-// if(! $(".contextMenuBody").is(":hidden")){
-// if(! $(e.target).parents(".contextMenuBody").length > 0){
-// $(".contextMenuBody").hide();
-// }
-// }
-// })
$('body').on("mouseup.contextMenu",function(e){
var selection;
if (window.getSelection) {
@@ -572,13 +478,6 @@ define(['require',
onDropDownMenuClick : function(e){
var $el = $(e.currentTarget),type=$el.data("id");
if(! _.isEmpty(this.selectionText)){
-// if(type == "F"){
-//// this.ui.find.val(this.selectionText);
-//// this.ui.find.trigger("keyup");
-// }else{
-// //this.vent.trigger("add:include:exclude",{type:type,value:this.selectionText});
-// this.vent.trigger("toggle:facet",{viewName:((type === "I") ? "include" : "exclude") +"ServiceColumns",key:Globals.serviceLogsColumns["log_message"],value:this.selectionText});
-// }
if(type === "I" || type === "E"){
this.vent.trigger("toggle:facet",{viewName:((type === "I") ? "include" : "exclude") +"ServiceColumns",
key:Globals.serviceLogsColumns["log_message"],value:this.selectionText});
@@ -637,7 +536,6 @@ define(['require',
})
$('body').css('overflow', 'hidden');
},
- /** closing the movable/resizable popup */
onDialogClosed: function() {
if (this.dialog) {
this.dialog.close && this.dialog.close();
@@ -715,8 +613,8 @@ define(['require',
if (d3.event.shiftKey && d.depth == 2) {
that.globalVent.trigger("render:tab",/*new LogFileView(*/{
params : _.extend({
- host : d.parent.name,
- component : d.name,
+ host_name : d.parent.name,
+ component_name : d.name,
// level : that.collection.queryParams.level,
// iMessage : that.collection.queryParams.iMessage,
// eMessage : that.collection.queryParams.eMessage,
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
index 2afb4e1..2d3b289 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
@@ -189,8 +189,8 @@ define(['require',
component = $el.data("type");
that.globalVent.trigger("render:tab",{
params:_.extend({},{
- host : host,
- component : component
+ host_name : host,
+ component_name : component
},that.searchParams,{treeParams:null}),
globalVent : that.globalVent
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/DashboardView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/DashboardView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/DashboardView.js
index 35814ba..461e132 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/DashboardView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/DashboardView.js
@@ -95,10 +95,6 @@ define(['require',
setupSelect2Fields: function(col, idKey, textKey, selectTagId){
var that = this, data = [];
data = _.pluck(col.models, 'attributes');
-// data = data.map(function(obj){
-// return {id : obj[idKey], text : obj[textKey]}
-// })
- //data.unshift({'id': null, 'text': null});
this.ui[selectTagId].select2({
placeholder: 'Select',
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/HostListView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/HostListView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/HostListView.js
index 7f169c1..b8c11d8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/HostListView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/HostListView.js
@@ -248,8 +248,8 @@ define(['require',
component = $el.data("node");
that.globalVent.trigger("render:tab",{
params:_.extend({},{
- host : host,
- component : component
+ host_name : host,
+ component_name : component
},that.searchParams,{treeParams:null}),
globalVent : that.globalVent
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
index 66593c4..aa79ead 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/MainLayoutView.js
@@ -87,13 +87,6 @@ define(['require',
*/
initialize: function(options) {
_.extend(this, _.pick(options,'globalVent'));
-// this.collection = new VLogList([], {
-// state: {
-// firstPage: 0,
-// pageSize: 50
-// }
-// });
-// this.collection.url = Globals.baseURL + "service/logs";
this.vent = new Backbone.Wreqr.EventAggregator();
this.dateUtil = Utils.dateUtil;
this.bindEvents();
@@ -137,8 +130,8 @@ define(['require',
if(params.host_name && params.component_name){
this.globalVent.trigger("render:tab",{
params:_.extend({},{
- host : params.host_name,
- component : params.component_name
+ host_name : params.host_name,
+ component_name : params.component_name
},params),
globalVent : this.globalVent
});
@@ -147,7 +140,7 @@ define(['require',
renderLogFileTab : function(view){
var that = this;
require(['views/tabs/LogFileView'], function(LogFileView){
- var tabName = (view.params.host + view.params.component).replace(/\./g,"_");
+ var tabName = (view.params.host_name + view.params.component_name).replace(/\./g,"_");
if(_.isUndefined(that[tabName])){
var region = {};
region[tabName] = '#' + tabName;
@@ -160,7 +153,7 @@ define(['require',
var region = that.getRegion(tabName);
region.show(new LogFileView(view));
that.$(".nav.nav-tabs").append('<li data-id="'+tabName+'" role="presentation">'+
- '<a data-id="'+tabName+'" data-host="'+view.params.host+'" data-component="'+view.params.component+'" href="#'+tabName+'" aria-controls="profile" role="tab" data-toggle="tab" title="'+view.params.host.split(".")[0]+' >> '+view.params.component+' ">'+view.params.host.split(".")[0]+'<b> >> </b>'+view.params.component+'</a>'+
+ '<a data-id="'+tabName+'" data-host="'+view.params.host_name+'" data-component="'+view.params.component_name+'" href="#'+tabName+'" aria-controls="profile" role="tab" data-toggle="tab" title="'+view.params.host_name.split(".")[0]+' >> '+view.params.component_name+' ">'+view.params.host_name.split(".")[0]+'<b> >> </b>'+view.params.component_name+'</a>'+
// '<span class="air air-top-right">'+
'<button data-tab-id="'+tabName+'" class="btn-closeTab"><i class="fa fa-times-circle"></i></button>'+
'<div class="compareClick" title="Compare"><i class="fa fa-square-o"></i></div>');
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/DetailLogFileView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/DetailLogFileView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/DetailLogFileView.js
index 5570a31..689bacd 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/DetailLogFileView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dialog/DetailLogFileView.js
@@ -68,8 +68,8 @@ define(['require',
onRender: function() {
var that = this;
this.fetchLogs({
- host : this.model.get("host"),
- component : this.model.get("type"),
+ host_name : this.model.get("host"),
+ component_name : this.model.get("type"),
numberRows : this.defaultRecords,
id : this.model.get("id")
},{
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js
index 9bdf0fa..2c7f0aa 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/filter/CreateLogfeederFilterView.js
@@ -211,10 +211,10 @@ define(['require',
onEditHost : function(e){
var $el = $(e.currentTarget);
$el.hide();
- if($el.data("type") == "host"){
- this.showHostSelect2($el.data("component"));
+ if($el.data("type") == "host_name"){
+ this.showHostSelect2($el.data("component_name"));
}else{
- this.showExpiry($el.data("component"));
+ this.showExpiry($el.data("component_name"));
}
},
hideHostSelect2 : function(forComponent){
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/ComparisonView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/ComparisonView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/ComparisonView.js
index f922087..7c50cbb 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/ComparisonView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/ComparisonView.js
@@ -27,7 +27,6 @@ define(['require',
'use strict';
return Backbone.Marionette.Layout.extend(
- /** @lends ComparisonView */
{
_viewName: 'ComparisonView',
@@ -80,8 +79,8 @@ define(['require',
onRender: function() {
if (this.params) {
this.fetchCollection(this.params);
- if (this.params.component && this.params.host) {
- this.ui.tabTitle.html(this.params.host + ' <i class="fa fa-angle-double-right"></i> ' + this.params.component)
+ if (this.params.component_name && this.params.host_name) {
+ this.ui.tabTitle.html(this.params.host_name + ' <i class="fa fa-angle-double-right"></i> ' + this.params.component_name)
}
} else {
this.fetchCollection({
@@ -91,9 +90,6 @@ define(['require',
this.renderVisualSearch();
this.renderDatePicker();
this.renderTable();
- /* if (this.params.from && this.params.to) {
- this.setDateText(this.dateUtil.getMomentObject(this.params.from), this.dateUtil.getMomentObject(this.params.to));
- }*/
},
renderVisualSearch: function() {
@@ -151,7 +147,6 @@ define(['require',
},
gridOpts: {
header: CustomBackgrid,
- //row: IdRow,
emptyText: 'No records found!'
},
filterOpts: {},
@@ -179,10 +174,7 @@ define(['require',
str += "<p>" + moment(rawValue).format("YYYY-MM-DD HH:mm:ss,SSS") + "</p>";
if (model.get("type"))
str += "<p style='float:left;width:90%'>" + (model.get("level") ? "<label class='label label-" + (""+model.get("level")).toUpperCase() + "'>" + (""+model.get("level")).toUpperCase() + "</label>" : "") +
- /* "<strong>" + model.get("type") + "</strong>" +*/
"</p><a style='width:9%' title='Open logs in new tab' data-type='C' data-host='" + model.get("host") + "' data-node='" + model.get("type") + "' href='javascript:void(0)' class='pull-right hidden'><i class='fa fa-share'></i></a>";
- // if(model.get("level"))
- // str += "<p style='float:left;'><label class='label label-"+model.get("level")+"'>"+model.get("level")+"</label></p>";
return str;
}
})
@@ -193,7 +185,6 @@ define(['require',
editable: false,
sortType: 'toggle',
sortable: false,
- //width : "50",
orderable: true,
displayOrder: 4,
className: "logMessage",
@@ -243,7 +234,7 @@ define(['require',
this.ui.dateRange.data('daterangepicker').setStartDate(start);
this.ui.dateRange.data('daterangepicker').setEndDate(end);
- },
+ }
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
index e4d327c..43ee5db 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/HierarchyTabLayoutView.js
@@ -1,488 +1,429 @@
/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
define(['require',
- 'backbone',
- 'utils/Globals',
- 'utils/Utils',
- 'moment',
- 'utils/ViewUtils',
- 'collections/VLogList',
- 'collections/VGroupList',
- 'hbs!tmpl/tabs/HierarchyTabLayoutView_tmpl'
-],function(require,Backbone,Globals,Utils,moment,ViewUtils,VLogList,VGroupList,HierarchyTabLayoutViewTmpl){
- 'use strict';
+ 'backbone',
+ 'utils/Globals',
+ 'utils/Utils',
+ 'moment',
+ 'utils/ViewUtils',
+ 'collections/VLogList',
+ 'collections/VGroupList',
+ 'hbs!tmpl/tabs/HierarchyTabLayoutView_tmpl'
+], function (require, Backbone, Globals, Utils, moment, ViewUtils, VLogList, VGroupList, HierarchyTabLayoutViewTmpl) {
+ 'use strict';
- return Backbone.Marionette.Layout.extend(
- /** @lends LogLevelView */
- {
- _viewName : 'HierarchyTabLayoutView',
+ return Backbone.Marionette.Layout.extend(
+ /** @lends LogLevelView */
+ {
+ _viewName: 'HierarchyTabLayoutView',
- template: HierarchyTabLayoutViewTmpl,
+ template: HierarchyTabLayoutViewTmpl,
- /** Layout sub regions */
- regions: {
- RTreeView : "#r_TreeView",
- RBubbleTable : "#r_BubbleTable",
- RLogLevel : "#r_LogLevel",
- RHistogram : "#r_Histogram",
- RVisualSearch : "#r_vsSearch",
- REventHistory : "#r_EventHistory",
- RVisualSearchIncCol : "#r_vsSearchIncCol",
- RVisualSearchExCol : "#r_vsSearchExCol",
- RDatePicker:"#r_DatePicker",
- RLogSnapShot:"#r_LogSnapShot",
- RAdvanceSearch:"#r_AdvanceSearch"
- },
+ /** Layout sub regions */
+ regions: {
+ RTreeView: "#r_TreeView",
+ RBubbleTable: "#r_BubbleTable",
+ RLogLevel: "#r_LogLevel",
+ RHistogram: "#r_Histogram",
+ RVisualSearch: "#r_vsSearch",
+ REventHistory: "#r_EventHistory",
+ RVisualSearchIncCol: "#r_vsSearchIncCol",
+ RVisualSearchExCol: "#r_vsSearchExCol",
+ RDatePicker: "#r_DatePicker",
+ RLogSnapShot: "#r_LogSnapShot",
+ RAdvanceSearch: "#r_AdvanceSearch"
+ },
- /** ui selector cache */
- ui: {
- applySearch : '#applySearch',
- searchBoxBtn : '[data-id="hierarchySearchBtn"]',
- searchBox : '[data-id="hierarchySearch"]',
- excludeComponents : "#excludeComponents",
- includeComponents : "#includeComponents",
- basicSearch:'[data-id="basicSearch"]',
- advanceSearch:'[data-id="advanceSearch"]',
- toggleTableAccessLog:'[data-id="toggleTableAccessLog"]'
- },
+ /** ui selector cache */
+ ui: {
+ applySearch: '#applySearch',
+ searchBoxBtn: '[data-id="hierarchySearchBtn"]',
+ searchBox: '[data-id="hierarchySearch"]',
+ excludeComponents: "#excludeComponents",
+ includeComponents: "#includeComponents",
+ basicSearch: '[data-id="basicSearch"]',
+ advanceSearch: '[data-id="advanceSearch"]',
+ toggleTableAccessLog: '[data-id="toggleTableAccessLog"]'
+ },
- /** ui events hash */
- events: function() {
- var events = {};
- events["click "+this.ui.applySearch] = 'applySearchBtn';
- events["click "+this.ui.searchBoxBtn] = 'onSearchLogClick';
- events["click .server-info a"] = 'onLogLevelClick';
- events["change "+ this.ui.toggleTableAccessLog] = 'onSearchSwitch';
+ /** ui events hash */
+ events: function () {
+ var events = {};
+ events["click " + this.ui.applySearch] = 'applySearchBtn';
+ events["click " + this.ui.searchBoxBtn] = 'onSearchLogClick';
+ events["click .server-info a"] = 'onLogLevelClick';
+ events["change " + this.ui.toggleTableAccessLog] = 'onSearchSwitch';
- return events;
- },
+ return events;
+ },
- /**
- * intialize a new LogLevelView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options,'globalVent'));
-// this.logLevelList = new VLogLevelList();
-// this.logLevelList.url = Globals.baseURL + "service/logs/levels/counts/namevalues";
-// this.logLevelList.modelAttrName = "vNameValues";
- this.columnCollection = new VLogList([],{
- state: {
- firstPage: 0,
- pageSize: 99999
- }
- });
- this.componentsList = new VGroupList([],{
- state: {
- firstPage: 0,
- pageSize: 99999
- }
- });
- this.componentsList.url = Globals.baseURL + "service/logs/components";
- this.vent = new Backbone.Wreqr.EventAggregator();
-
- this.defaultParams = ViewUtils.getDefaultParamsForHierarchy();
- this.bindEvents();
- },
- applyParamsDate:function(date){
- if (date) {
- var dateString = date.split(',');
- if(dateString.length){
- var checkDate = Utils.dateUtil.getMomentUTC(dateString[0]);
- if(checkDate.isValid()){
- if(dateString[1]){
- checkDate.millisecond(dateString[1])
- }else{
- checkDate.millisecond('000')
- }
- return checkDate.toJSON();
- }
- }
- }
- },
- bindEvents : function(){
-// this.listenTo(this.logLevelList,"reset",function(){
-// this.renderLogLevelCounts();
-// },this);
-// this.listenTo(this.vent,"main:search",function(value){
-// this.fetchLogLevelCounts(value);
-// },this);
-// this.listenTo(this.vent,"tree:search",function(value){
-// this.fetchLogLevelCounts(value);
-// });
-// this.listenTo(this.vent,"type:mustNot",function(value){
-// this.fetchLogLevelCounts(value);
-// });
- this.listenTo(this.componentsList, "reset", function(col, abc){
- this.setupSelect2Fields(col,"type", 'type', 'excludeComponents', 'Exclude Components');
- this.setupSelect2Fields(col,"type", 'type', 'includeComponents', 'Include Components');
- }, this);
- this.listenTo(this.vent,"reinitialize:filter:mustBe",function(value){
- this.reinitializeFilterMustBe(value);
- },this);
- this.listenTo(this.vent,"reinitialize:filter:mustNot",function(value){
- this.reinitializeFilterMustNot(value);
- },this);
- this.listenTo(this.vent,"add:include:exclude",function(value){
- //this.$(".vs-box").find(".fa-chevron-down").click();
- },this);
- this.listenTo(this.vent,"tab:refresh",function(params){
- this.reRenderComponents(params);
- },this);
+ /**
+ * intialize a new LogLevelView Layout
+ * @constructs
+ */
+ initialize: function (options) {
+ _.extend(this, _.pick(options, 'globalVent'));
+ this.columnCollection = new VLogList([], {
+ state: {
+ firstPage: 0,
+ pageSize: 99999
+ }
+ });
+ this.componentsList = new VGroupList([], {
+ state: {
+ firstPage: 0,
+ pageSize: 99999
+ }
+ });
+ this.componentsList.url = Globals.baseURL + "service/logs/components";
+ this.vent = new Backbone.Wreqr.EventAggregator();
- this.listenTo(this.globalVent,"reinitialize:serviceLogs",function(options){
- this.vent.trigger("reinitialize:filter:tree reinitialize:filter:include:exclude reinitialize:filter:bubbleTable"+
- " reinitialize:filter:mustNot reinitialize:filter:mustBe reinitialize:filter:level reinitialize:filter:logtime",options);
- },this);
- },
- onRender : function(){
- //this.renderTreeView();
- this.fetchServiceLogsColumns();
- this.renderLogLevel();
- this.renderEventHistory();
- this.renderHistogram();
- this.renderDatePicker();
- //this.renderVSSearch();
- this.renderLogSnapShot();
-// this.fetchLogLevelCounts({q:"*:*"});
- this.componentsList.fetch({reset:true});
- },
- onShow:function(){
+ this.defaultParams = ViewUtils.getDefaultParamsForHierarchy();
+ this.bindEvents();
+ },
+ applyParamsDate: function (date) {
+ if (date) {
+ var dateString = date.split(',');
+ if (dateString.length) {
+ var checkDate = Utils.dateUtil.getMomentUTC(dateString[0]);
+ if (checkDate.isValid()) {
+ if (dateString[1]) {
+ checkDate.millisecond(dateString[1])
+ } else {
+ checkDate.millisecond('000')
+ }
+ return checkDate.toJSON();
+ }
+ }
+ }
+ },
+ bindEvents: function () {
+ this.listenTo(this.componentsList, "reset", function (col, abc) {
+ this.setupSelect2Fields(col, "type", 'type', 'excludeComponents', 'Exclude Components');
+ this.setupSelect2Fields(col, "type", 'type', 'includeComponents', 'Include Components');
+ }, this);
+ this.listenTo(this.vent, "reinitialize:filter:mustBe", function (value) {
+ this.reinitializeFilterMustBe(value);
+ }, this);
+ this.listenTo(this.vent, "reinitialize:filter:mustNot", function (value) {
+ this.reinitializeFilterMustNot(value);
+ }, this);
+ this.listenTo(this.vent, "add:include:exclude", function (value) {
+ //this.$(".vs-box").find(".fa-chevron-down").click();
+ }, this);
+ this.listenTo(this.vent, "tab:refresh", function (params) {
+ this.reRenderComponents(params);
+ }, this);
- //this.REventHistory.currentView.genrateTimeline();
+ this.listenTo(this.globalVent, "reinitialize:serviceLogs", function (options) {
+ this.vent.trigger("reinitialize:filter:tree reinitialize:filter:include:exclude reinitialize:filter:bubbleTable" +
+ " reinitialize:filter:mustNot reinitialize:filter:mustBe reinitialize:filter:level reinitialize:filter:logtime", options);
+ }, this);
+ },
+ onRender: function () {
+ this.fetchServiceLogsColumns();
+ this.renderLogLevel();
+ this.renderEventHistory();
+ this.renderHistogram();
+ this.renderDatePicker();
+ this.renderLogSnapShot();
+ this.componentsList.fetch({reset: true});
+ },
+ onShow: function () {
- },
- fetchServiceLogsColumns : function(){
- var that = this;
- this.columnCollection.getServiceLogSchemaFields({},{
-// beforeSend : function(){
-// that.$("#loaderAudit").show();
-// },
- success : function(data){
- Globals.serviceLogsColumns = data;
- },
- error : function(error,data,status){
- var obj = JSON.parse(error.responseText);
- if(obj)
- Utils.notifyError({content:obj.msgDesc});
- },
- complete : function(){
- that.renderServiceColumnsVSSearch();
- that.renderBubbleTableView();
- }
- });
- },
-// fetchLogLevelCounts : function(params){
-// $.extend(this.logLevelList.queryParams,params);
-// this.logLevelList.fetch({reset:true});
-// },
- renderTreeView : function(){
- var that = this;
- require(['views/tabs/TreeView'],function(TreeView){
- that.RTreeView.show(new TreeView({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams
- }));
- });
- },
- renderBubbleTableView : function(){
- var that = this;
- require(['views/dashboard/BubbleGraphTableLayoutView'],function(BubbleTableLayoutView){
- that.RBubbleTable.show(new BubbleTableLayoutView({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams,
- columns:Globals.serviceLogsColumns,
- quickHelp : true
- }));
- });
- },
- renderLogLevel : function(){
- var that = this;
- require(['views/dashboard/LogLevelBoxView'],function(LogLevelBoxView){
- that.RLogLevel.show(new LogLevelBoxView({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams
- }));
- });
- },
- renderHistogram : function(){
- var that = this;
- require(['views/graphs/GraphLayoutView'],function(GraphLayoutView){
- that.RHistogram.show(new GraphLayoutView({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams,
- showUnit : true,
- futureDate : true
- }));
- });
- },
- renderDatePicker:function(){
- var that = this;
- require(['views/common/DatePickerLayout'],function(DatePickerLayout){
- that.RDatePicker.show(new DatePickerLayout({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams,
- datePickerPosition:'left',
- rangeLabel: true,
- parentEl: that.$el.find('.topLevelFilter')
- }));
- });
- },
- renderLogSnapShot:function(){
- var that = this;
- require(['views/common/LogSnapShotLayout'],function(LogSnalShopLayout){
- that.RLogSnapShot.show(new LogSnalShopLayout({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams,
- }));
- });
- },
- renderAdvanceSearch:function(){
- var that = this;
- require(['views/common/AdvanceSearchLayout'],function(AdvanceSearchLayout){
- that.RAdvanceSearch.show(new AdvanceSearchLayout({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams,
- }));
- });
+ },
+ fetchServiceLogsColumns: function () {
+ var that = this;
+ this.columnCollection.getServiceLogSchemaFields({}, {
+ success: function (data) {
+ Globals.serviceLogsColumns = ViewUtils.getLogSchemaFields(data, Globals.defaultServiceLogMappings, Globals.defaultServiceLogExcludes);
+ },
+ error: function (error, data, status) {
+ var obj = JSON.parse(error.responseText);
+ if (obj)
+ Utils.notifyError({content: obj.msgDesc});
+ },
+ complete: function () {
+ that.renderServiceColumnsVSSearch();
+ that.renderBubbleTableView();
+ }
+ });
+ },
+ renderTreeView: function () {
+ var that = this;
+ require(['views/tabs/TreeView'], function (TreeView) {
+ that.RTreeView.show(new TreeView({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams
+ }));
+ });
+ },
+ renderBubbleTableView: function () {
+ var that = this;
+ require(['views/dashboard/BubbleGraphTableLayoutView'], function (BubbleTableLayoutView) {
+ that.RBubbleTable.show(new BubbleTableLayoutView({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams,
+ columns: Globals.serviceLogsColumns,
+ quickHelp: true
+ }));
+ });
+ },
+ renderLogLevel: function () {
+ var that = this;
+ require(['views/dashboard/LogLevelBoxView'], function (LogLevelBoxView) {
+ that.RLogLevel.show(new LogLevelBoxView({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams
+ }));
+ });
+ },
+ renderHistogram: function () {
+ var that = this;
+ require(['views/graphs/GraphLayoutView'], function (GraphLayoutView) {
+ that.RHistogram.show(new GraphLayoutView({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams,
+ showUnit: true,
+ futureDate: true
+ }));
+ });
+ },
+ renderDatePicker: function () {
+ var that = this;
+ require(['views/common/DatePickerLayout'], function (DatePickerLayout) {
+ that.RDatePicker.show(new DatePickerLayout({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams,
+ datePickerPosition: 'left',
+ rangeLabel: true,
+ parentEl: that.$el.find('.topLevelFilter')
+ }));
+ });
+ },
+ renderLogSnapShot: function () {
+ var that = this;
+ require(['views/common/LogSnapShotLayout'], function (LogSnalShopLayout) {
+ that.RLogSnapShot.show(new LogSnalShopLayout({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams
+ }));
+ });
+ },
+ renderAdvanceSearch: function () {
+ var that = this;
+ require(['views/common/AdvanceSearchLayout'], function (AdvanceSearchLayout) {
+ that.RAdvanceSearch.show(new AdvanceSearchLayout({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams
+ }));
+ });
- },
- renderVSSearch : function(){
- var that = this;
- require(['views/tabs/VisualSearchView'],function(VisualSearchView){
- that.RVisualSearch.show(new VisualSearchView({
- viewName : "includeExclude",
- vent : that.vent,
- globalVent:that.globalVent,
- eventName : "search:include:exclude",
- myFormatData : function(query,searchCollection){
- var include = [],exclude=[];
- searchCollection.each(function(m){
- if(m.get("category") === "Exclude"){
- (! _.isEmpty(m.get("value"))) ? exclude.push(m.get("value")):'';
- }
- else{
- (! _.isEmpty(m.get("value"))) ? include.push(m.get("value")):'';
- }
- });
- return {
- iMessage : Utils.encodeIncludeExcludeStr(include,true),
- eMessage : Utils.encodeIncludeExcludeStr(exclude,true),
- query : query
- };
- }
+ },
+ renderVSSearch: function () {
+ var that = this;
+ require(['views/tabs/VisualSearchView'], function (VisualSearchView) {
+ that.RVisualSearch.show(new VisualSearchView({
+ viewName: "includeExclude",
+ vent: that.vent,
+ globalVent: that.globalVent,
+ eventName: "search:include:exclude",
+ myFormatData: function (query, searchCollection) {
+ var include = [], exclude = [];
+ searchCollection.each(function (m) {
+ if (m.get("category") === "Exclude") {
+ (!_.isEmpty(m.get("value"))) ? exclude.push(m.get("value")) : '';
+ }
+ else {
+ (!_.isEmpty(m.get("value"))) ? include.push(m.get("value")) : '';
+ }
+ });
+ return {
+ iMessage: Utils.encodeIncludeExcludeStr(include, true),
+ eMessage: Utils.encodeIncludeExcludeStr(exclude, true),
+ query: query
+ };
+ }
- }));
- });
- },
- renderServiceColumnsVSSearch : function(){
- //Columns include exclude
- var that = this;
- require(['views/tabs/VisualSearchView'],function(VisualSearchView){
- var data = _.values(Globals.serviceLogsColumns);
- var columns = _.without( data, _.findWhere( data, "logtime"));
- that.RVisualSearchIncCol.show(new VisualSearchView({
- viewName : "includeServiceColumns",
- placeholder : "Include Search",
- vent : that.vent,
- globalVent:that.globalVent,
- customOptions : columns,
- eventName : Globals.eventName.serviceLogsIncludeColumns,
- myFormatData : function(query,searchCollection){
- var obj=[];
- searchCollection.each(function(m){
- var data = {};
- data[m.get("category")] = m.get("value");
- obj.push(data);
- });
- return {
- includeQuery : JSON.stringify(obj),
- query : query
- }
- }
- }));
- that.RVisualSearchExCol.show(new VisualSearchView({
- viewName : "excludeServiceColumns",
- placeholder : "Exclude Search",
- vent : that.vent,
- globalVent:that.globalVent,
- customOptions : columns,
- eventName : Globals.eventName.serviceLogsExcludeColumns,
- myFormatData : function(query,searchCollection){
- var obj=[];
- searchCollection.each(function(m){
- var data = {};
- data[m.get("category")] = m.get("value");
- obj.push(data);
- });
- return {
- excludeQuery : JSON.stringify(obj),
- query : query
- }
- }
- }));
- });
- },
- renderEventHistory:function(){
- var that = this;
- require(['views/common/EventHistoryLayout'],function(EventHistoryLayoutView){
- that.REventHistory.show(new EventHistoryLayoutView({
- vent : that.vent,
- globalVent:that.globalVent,
- params : that.defaultParams
- }));
- });
- },
- fetchCollection : function(params){
- $.extend(this.collection.queryParams, params);
- this.collection.fetch({reset:true});
- },
- onSearchLogClick : function(){
- var value = this.ui.searchBox.val();
- if(_.isEmpty(value)){
- this.ui.searchBox.val("*:*");
- value = "*:*";
- }
- this.vent.trigger("main:search",{q:value});
- },
-// renderLogLevelCounts : function(){
-// var that = this;
-// this.logLevelList.each(function(model){
-// that.$("[data-total='"+model.get("name")+"']").text(model.get("value"));
-// });
-// },
-// onLogLevelClick : function(e){
-// var $el = $(e.currentTarget);
-// if($el.hasClass("active")){
-// $el.removeClass("active");
-// }else{
-// $el.addClass("active");
-// }
-// var params = [];
-// _.each(this.$(".server-info a.active"),function(e){
-// params.push($(e).find("strong").data("total"));
-// });
-// this.vent.trigger("level:filter",{level:params.toString()});
-// },
- setupSelect2Fields : function(col, idKey, textKey, selectTagId, placeHolder){
- var that = this, data = [];
- data = _.pluck(col.models, 'attributes');
-// data = data.map(function(obj){
-// return {id : obj[idKey], text : obj[textKey]}
-// })
- //data.unshift({'id': null, 'text': null});
- for(var i=0;i < data.length;i++){
- data[i].id = data[i].type;
- }
- this.ui[selectTagId].select2({
- dropdownParent: that.$el,
- placeholder: (placeHolder) ? placeHolder :'Select',
- tags:true,
- allowClear : true,
- width: '100%',
- data: { results: data, text: textKey},
- formatSelection: function(item){
- return item[textKey];
- },
- formatResult: function(item){
- return item[textKey];
- }
- }).off("change").on("change",function(e){
- var data = that.ui[selectTagId].select2("data").map(function(d){return d.type});
- if(selectTagId === "excludeComponents"){
- that.vent.trigger("tree:strike:component",data);
- that.vent.trigger("type:mustNot",{mustNot:data.toString()});
- }
- if(selectTagId === "includeComponents")
- that.vent.trigger("type:mustBe",{mustBe:data.toString()});
- });
- },
- reinitializeFilterMustBe : function(values){
- if(values.mustBe)
- this.ui.includeComponents.select2('val',values.mustBe.split(","));
- else
- this.ui.includeComponents.select2('val',[]);
- },
- reinitializeFilterMustNot : function(values){
- if(values.mustNot)
- this.ui.excludeComponents.select2('val',values.mustNot.split(","));
- else
- this.ui.excludeComponents.select2('val',[]);
+ }));
+ });
+ },
+ renderServiceColumnsVSSearch: function () {
+ var that = this;
+ require(['views/tabs/VisualSearchView'], function (VisualSearchView) {
+ var data = _.values(Globals.serviceLogsColumns);
+ var columns = _.without(data, _.findWhere(data, "logtime"));
+ that.RVisualSearchIncCol.show(new VisualSearchView({
+ viewName: "includeServiceColumns",
+ placeholder: "Include Search",
+ vent: that.vent,
+ globalVent: that.globalVent,
+ customOptions: columns,
+ eventName: Globals.eventName.serviceLogsIncludeColumns,
+ myFormatData: function (query, searchCollection) {
+ var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedServiceLogMappings, false);
+ return {
+ includeQuery: JSON.stringify(obj),
+ query: query
+ }
+ }
+ }));
+ that.RVisualSearchExCol.show(new VisualSearchView({
+ viewName: "excludeServiceColumns",
+ placeholder: "Exclude Search",
+ vent: that.vent,
+ globalVent: that.globalVent,
+ customOptions: columns,
+ eventName: Globals.eventName.serviceLogsExcludeColumns,
+ myFormatData: function (query, searchCollection) {
+ var obj = ViewUtils.replaceColumnNamesWithKeys(searchCollection, Globals.invertedServiceLogMappings, false);
+ return {
+ excludeQuery: JSON.stringify(obj),
+ query: query
+ }
+ }
+ }));
+ });
+ },
+ renderEventHistory: function () {
+ var that = this;
+ require(['views/common/EventHistoryLayout'], function (EventHistoryLayoutView) {
+ that.REventHistory.show(new EventHistoryLayoutView({
+ vent: that.vent,
+ globalVent: that.globalVent,
+ params: that.defaultParams
+ }));
+ });
+ },
+ fetchCollection: function (params) {
+ $.extend(this.collection.queryParams, params);
+ this.collection.fetch({reset: true});
+ },
+ onSearchLogClick: function () {
+ var value = this.ui.searchBox.val();
+ if (_.isEmpty(value)) {
+ this.ui.searchBox.val("*:*");
+ value = "*:*";
+ }
+ this.vent.trigger("main:search", {q: value});
+ },
+ setupSelect2Fields: function (col, idKey, textKey, selectTagId, placeHolder) {
+ var that = this, data = [];
+ data = _.pluck(col.models, 'attributes');
+ for (var i = 0; i < data.length; i++) {
+ data[i].id = data[i].type;
+ }
+ this.ui[selectTagId].select2({
+ dropdownParent: that.$el,
+ placeholder: (placeHolder) ? placeHolder : 'Select',
+ tags: true,
+ allowClear: true,
+ width: '100%',
+ data: {results: data, text: textKey},
+ formatSelection: function (item) {
+ return item[textKey];
+ },
+ formatResult: function (item) {
+ return item[textKey];
+ }
+ }).off("change").on("change", function (e) {
+ var data = that.ui[selectTagId].select2("data").map(function (d) {
+ return d.type
+ });
+ if (selectTagId === "excludeComponents") {
+ that.vent.trigger("tree:strike:component", data);
+ that.vent.trigger("type:mustNot", {mustNot: data.toString()});
+ }
+ if (selectTagId === "includeComponents")
+ that.vent.trigger("type:mustBe", {mustBe: data.toString()});
+ });
+ },
+ reinitializeFilterMustBe: function (values) {
+ if (values.mustBe)
+ this.ui.includeComponents.select2('val', values.mustBe.split(","));
+ else
+ this.ui.includeComponents.select2('val', []);
+ },
+ reinitializeFilterMustNot: function (values) {
+ if (values.mustNot)
+ this.ui.excludeComponents.select2('val', values.mustNot.split(","));
+ else
+ this.ui.excludeComponents.select2('val', []);
- },
- reRenderComponents : function(params){
- var iComponents = this.ui.includeComponents.val(),eComponents = this.ui.excludeComponents.val(),that=this;
- this.componentsList.fetch({
- reset : true,
- complete : function(){
- that.ui.includeComponents.select2('val',iComponents.split(","));
- that.ui.excludeComponents.select2('val',eComponents.split(","));
- }
- });
- },
- onSearchSwitch:function(e){
- var obj = {}
- if(e.target.checked){
- this.ui.advanceSearch.show();
- this.ui.applySearch.show();
- this.ui.basicSearch.hide();
- obj.advanceSearch = this.RAdvanceSearch.currentView.ui.searchArea.val();
- obj.includeQuery = null;
- obj.excludeQuery = null;
- } else{
- this.ui.advanceSearch.hide();
- this.ui.applySearch.hide();
- this.ui.basicSearch.show();
- obj = this.getIncludeExcludeColValues();
- obj.advanceSearch = null;
- }
+ },
+ reRenderComponents: function (params) {
+ var iComponents = this.ui.includeComponents.val(), eComponents = this.ui.excludeComponents.val(), that = this;
+ this.componentsList.fetch({
+ reset: true,
+ complete: function () {
+ that.ui.includeComponents.select2('val', iComponents.split(","));
+ that.ui.excludeComponents.select2('val', eComponents.split(","));
+ }
+ });
+ },
+ onSearchSwitch: function (e) {
+ var obj = {};
+ if (e.target.checked) {
+ this.ui.advanceSearch.show();
+ this.ui.applySearch.show();
+ this.ui.basicSearch.hide();
+ obj.advanceSearch = this.RAdvanceSearch.currentView.ui.searchArea.val();
+ obj.includeQuery = null;
+ obj.excludeQuery = null;
+ } else {
+ this.ui.advanceSearch.hide();
+ this.ui.applySearch.hide();
+ this.ui.basicSearch.show();
+ obj = this.getIncludeExcludeColValues();
+ obj.advanceSearch = null;
+ }
- this.vent.trigger('main:search',obj);
+ this.vent.trigger('main:search', obj);
- },
- applySearchBtn : function(){
- var obj = {}
- obj.advanceSearch = this.RAdvanceSearch.currentView.ui.searchArea.val();
+ },
+ applySearchBtn: function () {
+ var obj = {};
+ obj.advanceSearch = this.RAdvanceSearch.currentView.ui.searchArea.val();
- this.vent.trigger('main:search',obj);
+ this.vent.trigger('main:search', obj);
- },
- getIncludeExcludeColValues : function(){
- return _.extend(this.RVisualSearchIncCol.currentView.formatData(this.RVisualSearchIncCol.currentView.visualSearch.searchBox.value(),this.RVisualSearchIncCol.currentView.visualSearch.searchQuery),
- this.RVisualSearchExCol.currentView.formatData(this.RVisualSearchExCol.currentView.visualSearch.searchBox.value(),this.RVisualSearchExCol.currentView.visualSearch.searchQuery));
- },
- toggleSearchBackToBasicSearch : function(options){
- if(! this.ui.advanceSearch.is(":hidden")){
- this.ui.advanceSearch.hide();
- this.ui.basicSearch.show();
- this.ui.toggleTableAccessLog[0].checked = false;
- _.extend(options,this.getIncludeExcludeColValues(),{advanceSearch:null});
- }
- }
- });
+ },
+ getIncludeExcludeColValues: function () {
+ return _.extend(this.RVisualSearchIncCol.currentView.formatData(this.RVisualSearchIncCol.currentView.visualSearch.searchBox.value(), this.RVisualSearchIncCol.currentView.visualSearch.searchQuery),
+ this.RVisualSearchExCol.currentView.formatData(this.RVisualSearchExCol.currentView.visualSearch.searchBox.value(), this.RVisualSearchExCol.currentView.visualSearch.searchQuery));
+ },
+ toggleSearchBackToBasicSearch: function (options) {
+ if (!this.ui.advanceSearch.is(":hidden")) {
+ this.ui.advanceSearch.hide();
+ this.ui.basicSearch.show();
+ this.ui.toggleTableAccessLog[0].checked = false;
+ _.extend(options, this.getIncludeExcludeColValues(), {advanceSearch: null});
+ }
+ }
+ });
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js
index 0b32237..3740716 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js
@@ -478,14 +478,6 @@ define(['require',
var timeZone = moment().zoneAbbr(),
that = this,
cols = {};
- _.each(Globals.serviceLogsColumns, function(value, col) {
- cols[col] = {
- label: value,
- cell: "String",
- sortType: 'toggle',
- editable: false,
- }
- });
this.cols = {
logtime: {
label: "Log Time " + (!_.isEmpty(timeZone) ? "(" + timeZone + ")" : ""),
@@ -509,30 +501,6 @@ define(['require',
}
})
},
- /*type: {
- //label: "Type",
- cell: "String",
- editable: false,
- sortType: 'toggle',
- orderable : true,
- displayOrder :2
- },*/
- /*level : {
- label: "Level",
- cell: "html",
- editable: false,
- sortType: 'toggle',
- sortable : true,
- orderable : true,
- width : "5",
- displayOrder :3,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model){
- if(rawValue)
- return "<span class='"+rawValue+"'>"+rawValue+"</span>";
- }
- })
- },*/
log_message: {
label: "Message",
cell: "html",
@@ -569,31 +537,24 @@ define(['require',
displayOrder: 6,
width: 6
}
- /*host : {
- label: "Host",
- cell: "String",
- editable: false,
- sortType: 'toggle',
- orderable : true,
- displayOrder :5
- },
- logger_name : {
- cell: "String",
- editable: false,
- sortType: 'toggle',
- orderable : true,
- displayOrder :6
- }*/
};
- _.each(cols, function(c, k) {
- if (that.cols[k] == undefined) {
- that.cols[k] = c;
- } else {
- if (that.cols[k] && that.cols[k].label) {
- that.cols[k].label = c.label;
- }
+ _.each(this.columns, function(value){
+ var name = Globals.invertedServiceLogMappings[value];
+ if (columns[name] === undefined) {
+ var columnObj = {
+ name: Globals.invertedServiceLogMappings[value],
+ label:value,
+ cell: "String",
+ sortType: 'toggle',
+ editable: false
+ };
+ columns[name] = columnObj;
+ } else {
+ if (columns[name] && columns[name].label) {
+ columns[name].label = value;
}
+ }
});
return this.logFileCollection.constructor.getTableCols(this.cols, this.logFileCollection);
},
@@ -666,8 +627,8 @@ define(['require',
}
},
setHostName: function() {
- this.$("[data-id='hostName']").text(this.params.host);
- this.$("[data-id='componentName']").text(this.params.component);
+ this.$("[data-id='hostName']").text(this.params.host_name);
+ this.$("[data-id='componentName']").text(this.params.component_name);
},
getFindValue: function() {
return this.ui.find.val();
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/TreeView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/TreeView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/TreeView.js
index bcd2c80..c395495 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/TreeView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/TreeView.js
@@ -79,8 +79,6 @@ define(['require',
*/
initialize: function(options) {
_.extend(this, _.pick(options,'vent','globalVent','params'));
-// this.collection = new VLogLevel();
-// this.collection.url = Globals.baseURL+"service/logs/components/count";
this.treeModel = new VCommonModel();
this.searchParams = (this.params)? this.params :{};
this.bindEvents();
@@ -311,8 +309,8 @@ define(['require',
component = $el.data("node");
that.globalVent.trigger("render:tab",/*new LogFileView(*/{
params:_.extend({},{
- host : host,
- component : component
+ host_name : host,
+ component_name : component
},that.searchParams,{treeParams:null}),
globalVent : that.globalVent
}/*)*/);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/VisualSearchView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/VisualSearchView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/VisualSearchView.js
index 24e0211..8bfb85f 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/VisualSearchView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/VisualSearchView.js
@@ -1,255 +1,202 @@
/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
define(['require',
- 'backbone',
- 'utils/Globals',
- 'utils/Utils',
- 'collections/VLogLevelList',
- 'hbs!tmpl/tabs/VisualSearchView_tmpl',
- 'select2'
-],function(require,Backbone,Globals,Utils,VLogLevel,LogLevelTmpl){
- 'use strict';
+ 'backbone',
+ 'utils/Globals',
+ 'utils/Utils',
+ 'collections/VLogLevelList',
+ 'hbs!tmpl/tabs/VisualSearchView_tmpl',
+ 'select2'
+], function (require, Backbone, Globals, Utils, VLogLevel, LogLevelTmpl) {
+ 'use strict';
- return Backbone.Marionette.Layout.extend(
- /** @lends VisualSearchView */
- {
- _viewName : 'VisualSearchView',
+ return Backbone.Marionette.Layout.extend(
+ {
+ _viewName: 'VisualSearchView',
- template: LogLevelTmpl,
+ template: LogLevelTmpl,
- /** Layout sub regions */
- regions: {
- },
+ /** Layout sub regions */
+ regions: {},
- /** ui selector cache */
- ui: {
- vsContainer : "#vs_container",
- },
+ /** ui selector cache */
+ ui: {
+ vsContainer: "#vs_container",
+ },
- /** ui events hash */
- events: function() {
- var events = {};
- events['click #searchLog'] = 'onSearchLogClick';
- return events;
- },
+ /** ui events hash */
+ events: function () {
+ var events = {};
+ events['click #searchLog'] = 'onSearchLogClick';
+ return events;
+ },
- /**
- * intialize a new VisualSearchView Layout
- * @constructs
- */
- initialize: function(options) {
- _.extend(this, _.pick(options,'vent','globalVent','params','customOptions','eventName','myFormatData','placeholder', 'viewName'));
- this.bindEvents();
- },
- onRender : function(){
- var query="";
-// if(this.customOptions){
-//
-// }
-// if(this.params && this.params.query){
-// query = this.params.query;
-// }
- this.initializeSearch(this.formQueryDataFromParams(this.params));
- },
- bindEvents : function(){
- this.listenTo(this.vent,"reinitialize:filter:include:exclude",function(value){
- this.reinitializeFilter(value);
- });
- this.listenTo(this.vent,"add:include:exclude",function(value){
- this.addIncludeExclude(value);
- });
- this.listenTo(this.vent,"toggle:facet",function(obj){
- this.toggleFacet(obj);
+ initialize: function (options) {
+ _.extend(this, _.pick(options, 'vent', 'globalVent', 'params', 'customOptions', 'eventName', 'myFormatData', 'placeholder', 'viewName'));
+ this.bindEvents();
+ },
+ onRender: function () {
+ this.initializeSearch(this.formQueryDataFromParams(this.params));
+ },
+ bindEvents: function () {
+ this.listenTo(this.vent, "reinitialize:filter:include:exclude", function (value) {
+ this.reinitializeFilter(value);
+ });
+ this.listenTo(this.vent, "add:include:exclude", function (value) {
+ this.addIncludeExclude(value);
+ });
+ this.listenTo(this.vent, "toggle:facet", function (obj) {
+ this.toggleFacet(obj);
+ });
+ },
+ initializeSearch: function (query) {
+ var opts = (this.customOptions) ? this.customOptions : ["Include", "Exclude"], that = this;
+ this.visualSearch = VS.init({
+ placeholder: (!this.placeholder) ? "Search String" : this.placeholder,
+ container: this.ui.vsContainer,
+ query: query,
+ remainder: false,
+ callbacks: {
+ search: function (query, searchCollection) {
+ var eventName = (!that.eventName) ? "search:include:exclude" : that.eventName;
+ that.vent.trigger(eventName, that.formatData(query, searchCollection));
+ },
+ facetMatches: function (callback) {
+ callback(opts, {preserveOrder: true});
+ },
+ valueMatches: function (facet, searchTerm, callback) {
+ }
+ }
+ });
+ },
+ formatData: function (query, searchCollection) {
+ if (_.isFunction(this.myFormatData)) {
+ return this.myFormatData(query, searchCollection);
+ }
+ var include = [], exclude = [], obj = [], that = this;
+ searchCollection.each(function (m) {
+ if (!that.customOptions) {
+ if (m.get("category") === "Exclude") {
+ (!_.isEmpty(m.get("value"))) ? exclude.push(m.get("value")) : '';
+ }
+ else {
+ (!_.isEmpty(m.get("value"))) ? include.push(m.get("value")) : '';
+ }
+ } else {
+ var data = {};
+ data[m.get("category")] = m.get("value");
+ obj.push(data);
+ }
+
+ });
+ if (!this.customOptions) {
+ return {
+ iMessage: Utils.encodeIncludeExcludeStr(include, true),
+ eMessage: Utils.encodeIncludeExcludeStr(exclude, true),
+ query: query
+ };
+ } else {
+ return {
+ columnQuery: JSON.stringify(obj),
+ query: query
+ }
+ }
+
+
+ },
+ reinitializeFilter: function (values) {
+ var query = "";
+ if (this.viewName) {
+ query = this.formQueryDataFromParams(values);
+ }
+ if (!_.isUndefined(query)) {
+ this.initializeSearch(query);
+ }
+ },
+ addIncludeExclude: function (value) {
+ if (this.customOptions)
+ return;
+ if (value) {
+ var e = $.Event("keydown");
+ e.keyCode = 13;
+ this.visualSearch.searchBox.addFacet((value.type == "I") ? "Include" : "Exclude", value.value);
+ this.visualSearch.options.callbacks.search(this.visualSearch.searchBox.value(), this.visualSearch.searchQuery);
+ }
+ },
+ toggleFacet: function (obj) {
+ if (_.isObject(obj)) {
+ if (obj.viewName == this.viewName) {
+ var view = _.find(this.visualSearch.searchBox.facetViews, function (v) {
+ return v.model.get("category") === obj.key && v.model.get("value") === obj.value;
});
- },
- initializeSearch : function(query) {
- var that = this;
- var opts = (this.customOptions) ? this.customOptions : [ "Include", "Exclude" ],that=this;
- this.visualSearch = VS.init({
- placeholder : (!this.placeholder) ? "Search String" : this.placeholder,
- container : this.ui.vsContainer,
- query : query,
- remainder : false,
- callbacks : {
- search : function(query, searchCollection) {
- var eventName = (! that.eventName) ? "search:include:exclude" : that.eventName;
-// if(! that.customOptions)
-// that.vent.trigger("search:include:exclude",that.formatData(query,searchCollection));
-// else
-// that.vent.trigger("search:audit:query",that.formatData(query,searchCollection));
- that.vent.trigger(eventName,that.formatData(query,searchCollection));
- },
- facetMatches : function(callback) {
-// var searchOptTemp = $.extend(true, [], opts);
-// that.visualSearch.searchQuery.each(function(m) {
-// if ($.inArray(m.get('category'), searchOptTemp) >= 0) {
-// searchOptTemp.splice($.inArray(m.get('category'),
-// searchOptTemp), 1);
-// }
-// });
-// callback(searchOptTemp,{preserveOrder: true});
- callback(opts,{preserveOrder: true});
- },
- valueMatches : function(facet, searchTerm, callback) {
-// that.$('vsLoader').show();
-// $.ajax({
-// url: '/service/dashboard/getSuggestoins?fieldName='+facet+'&valueToSuggest='+searchTerm+'',
-// type: 'GET',
-// success: function(result){
-// console.log(result);
-// callback(result,{preserveOrder: false});
-// },
-// error:function(){},
-// complete:function(){
-// //that.$('vsLoader').hide();
-// }
-// });
- }
- }
- });
- },
- formatData : function(query,searchCollection){
- if(_.isFunction(this.myFormatData)){
- return this.myFormatData(query,searchCollection);
- }
- var include = [],exclude=[],obj=[],that=this;
- searchCollection.each(function(m){
- if(! that.customOptions){
- if(m.get("category") === "Exclude"){
- (! _.isEmpty(m.get("value"))) ? exclude.push(m.get("value")):'';
- }
- else{
- (! _.isEmpty(m.get("value"))) ? include.push(m.get("value")):'';
- }
- }else{
- var data = {};
- data[m.get("category")] = m.get("value");
- obj.push(data);
- }
-
- });
- if(! this.customOptions){
- return {
- iMessage : Utils.encodeIncludeExcludeStr(include,true),
- eMessage : Utils.encodeIncludeExcludeStr(exclude,true),
- query : query
- };
- }else{
- return {
- columnQuery : JSON.stringify(obj),
- query : query
- }
- }
-
-
- },
- reinitializeFilter : function(values){
- var query = "";
- if(this.viewName){
- query = this.formQueryDataFromParams(values);
- }
- if(! _.isUndefined(query)){
- this.initializeSearch(query);
- //this.vent.trigger("search:include:exclude",values);
- }
- },
- addIncludeExclude : function(value){
- //If this view is running for options other then Include/Exclude than return
- if(this.customOptions)
- return
- if(value){
- var e = $.Event("keydown");
- e.keyCode = 13;
- this.visualSearch.searchBox.addFacet((value.type == "I") ? "Include" : "Exclude",value.value);
- this.visualSearch.options.callbacks.search(this.visualSearch.searchBox.value(), this.visualSearch.searchQuery);
-// this.visualSearch.searchBox.searchEvent(e);
-// this.visualSearch.searchBox.removeFocus();
- }
- },
- toggleFacet : function(obj){
- if(_.isObject(obj)){
- if(obj.viewName == this.viewName){
-// var e = $.Event("click");
-// e.keyCode = 13;
-// var model = _.find(this.visualSearch.searchQuery.models,function(m){
-// return m.get("category") === obj.key && m.get("value") === obj.value;
-// });
- //obj.value = obj.value.replace(/:/, '\\\\:').replace(/\"/g, '\\"').replace(/\n/g, "\\n");
- var view = _.find(this.visualSearch.searchBox.facetViews,function(v){
- return v.model.get("category") === obj.key && v.model.get("value") === obj.value;
- });
- if(view){
- var e = $.Event("click");
- e.keyCode = 13;
- view.model.set("value",undefined);
- view.remove(e);
- }else
- this.visualSearch.searchBox.addFacet(obj.key,obj.value);
-// var keypress = $.Event("keydown");
-// keypress.keyCode = 13;
-// this.visualSearch.searchBox.searchEvent(keypress);
-// this.visualSearch.searchBox.removeFocus();
- this.visualSearch.options.callbacks.search(this.visualSearch.searchBox.value(), this.visualSearch.searchQuery);
- }
- }
- },
- formQueryDataFromParams : function(values){
- if(!values)
- return
- var query = "";
- try{
- var arr;
- if(this.viewName == "includeServiceColumns" && values.includeQuery){
- arr = JSON.parse(values.includeQuery);
- }else if(this.viewName == "excludeServiceColumns" && values.excludeQuery){
- arr = JSON.parse(values.excludeQuery);
- }
- if(_.isArray(arr)){
- for(var i=0; i<arr.length; i++){
- var key = _.keys(arr[i])[0];
- query += "'"+key+ "':'" +arr[i][key] +"' ";
- }
- }
- if(this.viewName === "includeExclude" && (values.iMessage || values.eMessage)){
- var valuesArr,key;
- if(values.iMessage){
- valuesArr = values.iMessage.split(Globals.splitToken);
- key = "Include: ";
- for(var i=0; i<valuesArr.length; i++){
- query += key+ '"'+valuesArr[i]+'" ';
- }
- }
- if(values.eMessage){
- valuesArr = values.eMessage.split(Globals.splitToken);
- key = "Exclude: ";
- for(var i=0; i<valuesArr.length; i++){
- query += key+ '"'+valuesArr[i]+'" ';
- }
- }
-
-
- }
- }catch(e){
- console.log("Error",e);
- }
- return query;
- }
- });
-
-
+ if (view) {
+ var e = $.Event("click");
+ e.keyCode = 13;
+ view.model.set("value", undefined);
+ view.remove(e);
+ } else
+ this.visualSearch.searchBox.addFacet(obj.key, obj.value);
+ this.visualSearch.options.callbacks.search(this.visualSearch.searchBox.value(), this.visualSearch.searchQuery);
+ }
+ }
+ },
+ formQueryDataFromParams: function (values) {
+ if (!values)
+ return;
+ var query = "";
+ try {
+ var arr;
+ if (this.viewName == "includeServiceColumns" && values.includeQuery) {
+ arr = JSON.parse(values.includeQuery);
+ } else if (this.viewName == "excludeServiceColumns" && values.excludeQuery) {
+ arr = JSON.parse(values.excludeQuery);
+ }
+ if (_.isArray(arr)) {
+ for (var i = 0; i < arr.length; i++) {
+ var key = _.keys(arr[i])[0];
+ query += "'" + key + "':'" + arr[i][key] + "' ";
+ }
+ }
+ if (this.viewName === "includeExclude" && (values.iMessage || values.eMessage)) {
+ var valuesArr, key;
+ if (values.iMessage) {
+ valuesArr = values.iMessage.split(Globals.splitToken);
+ key = "Include: ";
+ for (var i = 0; i < valuesArr.length; i++) {
+ query += key + '"' + valuesArr[i] + '" ';
+ }
+ }
+ if (values.eMessage) {
+ valuesArr = values.eMessage.split(Globals.splitToken);
+ key = "Exclude: ";
+ for (var i = 0; i < valuesArr.length; i++) {
+ query += key + '"' + valuesArr[i] + '" ';
+ }
+ }
+ }
+ } catch (e) {
+ console.log("Error", e);
+ }
+ return query;
+ }
+
+
+ });
+
+
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/static/schema_fields.json
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/static/schema_fields.json b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/static/schema_fields.json
new file mode 100644
index 0000000..8620c11
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/static/schema_fields.json
@@ -0,0 +1,71 @@
+{
+ "serviceLogMappings": {
+ "log_message": "Message",
+ "bundle_id": "Bundle Id",
+ "case_id": "Case Id",
+ "cluster": "Cluster",
+ "event_count": "Event Count",
+ "file": "File",
+ "host": "Host",
+ "id": "Id",
+ "ip": "Ip",
+ "level": "Level",
+ "line_number": "Line Number",
+ "logtype": "Log Type",
+ "logfile_line_number": "Logfile Line Number",
+ "logger_name": "Logger Name",
+ "logtime": "logtime",
+ "method": "Method",
+ "path": "Path",
+ "rowtype": "Row Type",
+ "thread_name": "Thread",
+ "type": "Type"
+ },
+ "serviceLogExcludes": ["tags", "text", "message", "seq_num"],
+ "auditLogMappings": {
+ "enforcer": "Access Enforcer",
+ "access": "Access Type",
+ "action": "Action",
+ "agent": "Agent",
+ "agentHost": "Agent Host",
+ "authType": "Auth Type",
+ "bundle_id": "Bundle Id",
+ "case_id": "Case Id",
+ "cliIP": "Client Ip",
+ "cliType": "Client Type",
+ "cluster": "Cluster",
+ "dst": "DST",
+ "event_count": "Event Count",
+ "evtTime": "Event Time",
+ "file": "File",
+ "host": "Host",
+ "id": "Id",
+ "ip": "IP",
+ "level": "Level",
+ "log_message": "Log Message",
+ "logType": "Log Type",
+ "logfile_line_number": "Logfile Line Number",
+ "logger_name": "Logger Name",
+ "logtime": "logtime",
+ "path": "Path",
+ "perm": "Perm",
+ "policy": "Policy",
+ "proxyUsers": "Proxy Users",
+ "reason": "Reason",
+ "repo": "Repo",
+ "repoType": "Repo Type",
+ "req_caller_id": "Req Caller Id",
+ "reqContext": "Req Context",
+ "reqData": "Req Data",
+ "req_self_id": "Req Self Id",
+ "resType": "Res Type",
+ "resource": "Resource",
+ "result": "Result",
+ "sess": "Sess",
+ "text": "Text",
+ "type": "Type",
+ "ugi": "UGI",
+ "reqUser": "User"
+ },
+ "auditLogExcludes": ["tags","tags_str", "seq_num"]
+}
\ No newline at end of file
[5/6] ambari git commit: AMBARI-18310. Refactor logsearch portal code
- part 3 (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
new file mode 100644
index 0000000..ed93b4d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.dao;
+
+import org.apache.ambari.logsearch.conf.SolrPropsConfig;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+@Component
+public class SolrCollectionDao {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SolrCollectionDao.class);
+
+ private static final String ROUTER_FIELD = "_router_field_";
+ private static final int SETUP_RETRY_SECOND = 30;
+
+ /**
+ * This will try to get the collections from the Solr. Ping doesn't work if
+ * collection is not given
+ */
+ public boolean checkSolrStatus(CloudSolrClient cloudSolrClient) {
+ int waitDurationMS = 3 * 60 * 1000;
+ boolean status = false;
+ try {
+ long beginTimeMS = System.currentTimeMillis();
+ long waitIntervalMS = 2000;
+ int pingCount = 0;
+ while (true) {
+ pingCount++;
+ try {
+ List<String> collectionList = getCollections(cloudSolrClient);
+ if (collectionList != null) {
+ LOG.info("checkSolrStatus(): Solr getCollections() is success. collectionList=" + collectionList);
+ status = true;
+ break;
+ }
+ } catch (Exception ex) {
+ LOG.error("Error while doing Solr check", ex);
+ }
+ if (System.currentTimeMillis() - beginTimeMS > waitDurationMS) {
+ LOG.error("Solr is not reachable even after " + (System.currentTimeMillis() - beginTimeMS) + " ms. " +
+ "If you are using alias, then you might have to restart LogSearch after Solr is up and running.");
+ break;
+ } else {
+ LOG.warn("Solr is not not reachable yet. getCollections() attempt count=" + pingCount + ". " +
+ "Will sleep for " + waitIntervalMS + " ms and try again.");
+ }
+ Thread.sleep(waitIntervalMS);
+
+ }
+ } catch (Throwable t) {
+ LOG.error("Seems Solr is not up.");
+ }
+ return status;
+ }
+
+ public void setupCollections(final CloudSolrClient solrClient, final SolrPropsConfig solrPropsConfig) throws Exception {
+ boolean setupStatus = createCollectionsIfNeeded(solrClient, solrPropsConfig);
+ LOG.info("Setup status for " + solrPropsConfig.getCollection() + " is " + setupStatus);
+ if (!setupStatus) {
+ // Start a background thread to do setup
+ Thread setupThread = new Thread("setup_collection_" + solrPropsConfig.getCollection()) {
+ @Override
+ public void run() {
+ LOG.info("Started monitoring thread to check availability of Solr server. collection=" + solrPropsConfig.getCollection());
+ int retryCount = 0;
+ while (true) {
+ try {
+ Thread.sleep(SETUP_RETRY_SECOND * 1000);
+ retryCount++;
+ boolean setupStatus = createCollectionsIfNeeded(solrClient, solrPropsConfig);
+ if (setupStatus) {
+ LOG.info("Setup for collection " + solrPropsConfig.getCollection() + " is successful. Exiting setup retry thread");
+ break;
+ }
+ } catch (InterruptedException sleepInterrupted) {
+ LOG.info("Sleep interrupted while setting up collection " + solrPropsConfig.getCollection());
+ break;
+ } catch (Exception e) {
+ LOG.error("Error setting up collection=" + solrPropsConfig.getCollection(), e);
+ }
+ LOG.error("Error setting collection. collection=" + solrPropsConfig.getCollection() + ", retryCount=" + retryCount);
+ }
+ }
+ };
+ setupThread.setDaemon(true);
+ setupThread.start();
+ }
+ }
+
+ private boolean createCollectionsIfNeeded(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig) {
+ boolean result = false;
+ try {
+ List<String> allCollectionList = getCollections(solrClient);
+ if (solrPropsConfig.getSplitInterval().equalsIgnoreCase("none")) {
+ result = createCollection(solrClient, solrPropsConfig, allCollectionList);
+ } else {
+ result = setupCollectionsWithImplicitRouting(solrClient, solrPropsConfig, allCollectionList);
+ }
+ } catch (Exception ex) {
+ LOG.error("Error creating collection. collectionName=" + solrPropsConfig.getCollection(), ex);
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<String> getCollections(CloudSolrClient solrClient) throws SolrServerException,
+ IOException {
+ try {
+ CollectionAdminRequest.List colListReq = new CollectionAdminRequest.List();
+ CollectionAdminResponse response = colListReq.process(solrClient);
+ if (response.getStatus() != 0) {
+ LOG.error("Error getting collection list from solr. response=" + response);
+ return null;
+ }
+ return (List<String>) response.getResponse().get("collections");
+ } catch (SolrException e) {
+ LOG.error("getCollections() operation failed", e);
+ return new ArrayList<>();
+ }
+ }
+
+ private boolean setupCollectionsWithImplicitRouting(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig, List<String> allCollectionList)
+ throws Exception {
+ LOG.info("setupCollectionsWithImplicitRouting(). collectionName=" + solrPropsConfig.getCollection()
+ + ", numberOfShards=" + solrPropsConfig.getNumberOfShards());
+
+ // Default is true, because if the collection and shard is already there, then it will return true
+ boolean returnValue = true;
+
+ List<String> shardsList = new ArrayList<String>();
+ for (int i = 0; i < solrPropsConfig.getNumberOfShards(); i++) {
+ shardsList.add("shard" + i);
+ }
+ String shardsListStr = StringUtils.join(shardsList, ',');
+
+ // Check if collection is already in zookeeper
+ if (!allCollectionList.contains(solrPropsConfig.getCollection())) {
+ LOG.info("Creating collection " + solrPropsConfig.getCollection() + ", shardsList=" + shardsList);
+ CollectionAdminRequest.Create collectionCreateRequest = new CollectionAdminRequest.Create();
+ collectionCreateRequest.setCollectionName(solrPropsConfig.getCollection());
+ collectionCreateRequest.setRouterName("implicit");
+ collectionCreateRequest.setShards(shardsListStr);
+ collectionCreateRequest.setNumShards(solrPropsConfig.getNumberOfShards());
+ collectionCreateRequest.setReplicationFactor(solrPropsConfig.getReplicationFactor());
+ collectionCreateRequest.setConfigName(solrPropsConfig.getConfigName());
+ collectionCreateRequest.setRouterField(ROUTER_FIELD);
+ collectionCreateRequest.setMaxShardsPerNode(solrPropsConfig.getReplicationFactor() * solrPropsConfig.getNumberOfShards());
+
+ CollectionAdminResponse createResponse = collectionCreateRequest.process(solrClient);
+ if (createResponse.getStatus() != 0) {
+ returnValue = false;
+ LOG.error("Error creating collection. collectionName=" + solrPropsConfig.getCollection()
+ + ", shardsList=" + shardsList +", response=" + createResponse);
+ } else {
+ LOG.info("Created collection " + solrPropsConfig.getCollection() + ", shardsList=" + shardsList);
+ }
+ } else {
+ LOG.info("Collection " + solrPropsConfig.getCollection() + " is already there. Will check whether it has the required shards");
+ Collection<String> existingShards = getShards(solrClient, solrPropsConfig);
+ for (String shard : shardsList) {
+ if (!existingShards.contains(shard)) {
+ try {
+ LOG.info("Going to add Shard " + shard + " to collection " + solrPropsConfig.getCollection());
+ CollectionAdminRequest.CreateShard createShardRequest = new CollectionAdminRequest.CreateShard();
+ createShardRequest.setCollectionName(solrPropsConfig.getCollection());
+ createShardRequest.setShardName(shard);
+ CollectionAdminResponse response = createShardRequest.process(solrClient);
+ if (response.getStatus() != 0) {
+ LOG.error("Error creating shard " + shard + " in collection " + solrPropsConfig.getCollection() + ", response=" + response);
+ returnValue = false;
+ break;
+ } else {
+ LOG.info("Successfully created shard " + shard + " in collection " + solrPropsConfig.getCollection());
+ }
+ } catch (Throwable t) {
+ LOG.error("Error creating shard " + shard + " in collection " + solrPropsConfig.getCollection(), t);
+ returnValue = false;
+ break;
+ }
+ }
+ }
+ }
+ return returnValue;
+ }
+
+ private Collection<String> getShards(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig) {
+ Collection<String> list = new HashSet<>();
+ ZkStateReader reader = solrClient.getZkStateReader();
+ Collection<Slice> slices = reader.getClusterState().getSlices(solrPropsConfig.getCollection());
+ for (Slice slice : slices) {
+ for (Replica replica : slice.getReplicas()) {
+ LOG.info("colName=" + solrPropsConfig.getCollection() + ", slice.name=" + slice.getName() + ", slice.state=" + slice.getState() +
+ ", replica.core=" + replica.getStr("core") + ", replica.state=" + replica.getStr("state"));
+ list.add(slice.getName());
+ }
+ }
+ return list;
+ }
+
+ private boolean createCollection(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig, List<String> allCollectionList) throws SolrServerException, IOException {
+
+ if (allCollectionList.contains(solrPropsConfig.getCollection())) {
+ LOG.info("Collection " + solrPropsConfig.getCollection() + " is already there. Won't create it");
+ return true;
+ }
+
+ LOG.info("Creating collection " + solrPropsConfig.getCollection() + ", numberOfShards=" + solrPropsConfig.getNumberOfShards() +
+ ", replicationFactor=" + solrPropsConfig.getReplicationFactor());
+
+ CollectionAdminRequest.Create collectionCreateRequest = new CollectionAdminRequest.Create();
+ collectionCreateRequest.setCollectionName(solrPropsConfig.getCollection());
+ collectionCreateRequest.setNumShards(solrPropsConfig.getNumberOfShards());
+ collectionCreateRequest.setReplicationFactor(solrPropsConfig.getReplicationFactor());
+ collectionCreateRequest.setConfigName(solrPropsConfig.getConfigName());
+ collectionCreateRequest.setMaxShardsPerNode(solrPropsConfig.getReplicationFactor() * solrPropsConfig.getNumberOfShards());
+ CollectionAdminResponse createResponse = collectionCreateRequest.process(solrClient);
+ if (createResponse.getStatus() != 0) {
+ LOG.error("Error creating collection. collectionName=" + solrPropsConfig.getCollection() + ", response=" + createResponse);
+ return false;
+ } else {
+ LOG.info("Created collection " + solrPropsConfig.getCollection() + ", numberOfShards=" + solrPropsConfig.getNumberOfShards() +
+ ", replicationFactor=" + solrPropsConfig.getReplicationFactor());
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
index ac7f56f..8381948 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
@@ -22,426 +22,47 @@ package org.apache.ambari.logsearch.dao;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Date;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
+import java.util.Map;
-import org.apache.ambari.logsearch.common.ConfigHelper;
import org.apache.ambari.logsearch.common.LogSearchContext;
import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
-import org.apache.ambari.logsearch.conf.SolrUserConfig;
import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
+import org.apache.ambari.logsearch.model.response.BarGraphData;
+import org.apache.ambari.logsearch.model.response.NameValueData;
+import org.apache.ambari.logsearch.util.DateUtil;
import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.client.solrj.impl.HttpClientUtil;
-import org.apache.solr.client.solrj.impl.HttpSolrClient;
-import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
-import org.apache.solr.client.solrj.request.CollectionAdminRequest;
-import org.apache.solr.client.solrj.request.schema.SchemaRequest;
-import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.client.solrj.response.schema.SchemaResponse;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.cloud.Replica;
-import org.apache.solr.common.cloud.Slice;
-import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.NamedList;
-
-import com.google.common.annotations.VisibleForTesting;
-
-import javax.inject.Inject;
+import org.apache.solr.common.util.SimpleOrderedMap;
public abstract class SolrDaoBase {
- private static final Logger logger = Logger.getLogger(SolrDaoBase.class);
- private static final Logger logPerformance = Logger.getLogger("org.apache.ambari.logsearch.performance");
-
- public HashMap<String, String> schemaFieldsNameMap = new HashMap<String, String>();
- public HashMap<String, String> schemaFieldTypeMap = new HashMap<String, String>();
-
- private static final String ROUTER_FIELD = "_router_field_";
-
- private static final int SETUP_RETRY_SECOND = 30;
- private static final int SETUP_UPDATE_SECOND = 10*60; //10 min
- private static final int ALIAS_SETUP_RETRY_SECOND = 30*60;
- private LogType logType;
-
- @VisibleForTesting
- protected String collectionName = null;
- @VisibleForTesting
- protected SolrClient solrClient = null;
- @VisibleForTesting
- protected CloudSolrClient solrClouldClient = null;
- @VisibleForTesting
- protected boolean isZkConnectString = false;
-
- private String solrDetail = "";
+ private static final Logger LOG_PERFORMANCE = Logger.getLogger("org.apache.ambari.logsearch.performance");
- private boolean populateFieldsThreadActive = false;
+ public Map<String, String> schemaFieldNameMap = new HashMap<>();
+ public Map<String, String> schemaFieldTypeMap = new HashMap<>();
- @Inject
- private SolrKerberosConfig solrKerberosConfig;
- @Inject
- private SolrUserConfig solrUserConfig;
+ private LogType logType;
protected SolrDaoBase(LogType logType) {
this.logType = logType;
}
- protected SolrClient connectToSolr(String url, String zkConnectString, String collection) throws Exception {
- this.collectionName = collection;
- solrDetail = "zkConnectString=" + zkConnectString + ", collection=" + collection + ", url=" + url;
-
- logger.info("connectToSolr() " + solrDetail);
- if (StringUtils.isBlank(collection)) {
- throw new Exception("For solr, collection name is mandatory. " + solrDetail);
- }
-
- setupSecurity();
-
- if (solrClient != null) {
- return solrClient;
- }
-
- if (!StringUtils.isBlank(zkConnectString)) {
- isZkConnectString = true;
- solrDetail = "zkConnectString=" + zkConnectString + ", collection=" + collection;
- logger.info("Using zookeeper. " + solrDetail);
- solrClouldClient = new CloudSolrClient(zkConnectString);
- solrClouldClient.setDefaultCollection(collection);
- solrClient = solrClouldClient;
- int waitDurationMS = 3 * 60 * 1000;
- checkSolrStatus(waitDurationMS);
- } else {
- if (StringUtils.isBlank(url)) {
- throw new Exception("Both zkConnectString and URL are empty. zkConnectString=" + zkConnectString + ", " +
- "collection=" + collection + ", url=" + url);
- }
- solrDetail = "collection=" + collection + ", url=" + url;
- String collectionURL = url + "/" + collection;
- logger.info("Connecting to solr : " + collectionURL);
- solrClient = new HttpSolrClient(collectionURL);
- }
- return solrClient;
- }
-
- /**
- * This will try to get the collections from the Solr. Ping doesn't work if
- * collection is not given
- */
- protected boolean checkSolrStatus(int waitDurationMS) {
- boolean status = false;
- try {
- long beginTimeMS = System.currentTimeMillis();
- long waitIntervalMS = 2000;
- int pingCount = 0;
- while (true) {
- pingCount++;
- try {
- List<String> collectionList = getCollections();
- if (collectionList != null) {
- logger.info("checkSolrStatus(): Solr getCollections() is success. solr=" + solrDetail + ", collectionList=" + collectionList);
- status = true;
- break;
- }
- } catch (Exception ex) {
- logger.error("Error while doing Solr check", ex);
- }
- if (System.currentTimeMillis() - beginTimeMS > waitDurationMS) {
- logger.error("Solr is not reachable even after " + (System.currentTimeMillis() - beginTimeMS) + " ms. " +
- "If you are using alias, then you might have to restart LogSearch after Solr is up and running. solr=" + solrDetail);
- break;
- } else {
- logger.warn("Solr is not not reachable yet. getCollections() attempt count=" + pingCount + ". " +
- "Will sleep for " + waitIntervalMS + " ms and try again." + " solr=" + solrDetail);
- }
- Thread.sleep(waitIntervalMS);
-
- }
- } catch (Throwable t) {
- logger.error("Seems Solr is not up. solrDetail=" + solrDetail);
- }
- return status;
- }
-
- protected void setupAlias(final String aliasNameIn, final Collection<String> collectionListIn ) throws Exception {
- if (aliasNameIn == null || collectionListIn == null || collectionListIn.size() == 0 || solrClouldClient == null) {
- logger.info("Will not create alias " + aliasNameIn + " for " +
- (collectionListIn == null ? null: collectionListIn.toString()) + ", solrCloudClient=" + solrClouldClient);
- return;
- }
-
- logger.info("setupAlias " + aliasNameIn + " for " + (collectionListIn == null ? null: collectionListIn.toString()));
- // Start a background thread to do setup
- Thread setupThread = new Thread("setup_alias_" + aliasNameIn) {
- @Override
- public void run() {
- logger.info("Started monitoring thread to check availability of Solr server. alias=" + aliasNameIn +
- ", collections=" + collectionListIn.toString());
- int retryCount = 0;
- while (true) {
- try {
- int count = createAlias(aliasNameIn, collectionListIn);
- if (count > 0) {
- solrClouldClient.setDefaultCollection(aliasNameIn);
- if (count == collectionListIn.size()) {
- logger.info("Setup for alias " + aliasNameIn + " is successful. Exiting setup retry thread. " +
- "Collections=" + collectionListIn);
- populateSchemaFields();
- break;
- }
- } else {
- logger.warn("Not able to create alias=" + aliasNameIn + ", retryCount=" + retryCount);
- }
- } catch (Exception e) {
- logger.error("Error setting up alias=" + aliasNameIn, e);
- }
- try {
- Thread.sleep(ALIAS_SETUP_RETRY_SECOND * 1000);
- } catch (InterruptedException sleepInterrupted) {
- logger.info("Sleep interrupted while setting up alias " + aliasNameIn);
- break;
- }
- retryCount++;
- }
- }
- };
- setupThread.setDaemon(true);
- setupThread.start();
- }
-
- private int createAlias(String aliasNameIn, Collection<String> collectionListIn) throws SolrServerException, IOException {
- List<String> collectionToAdd = getCollections();
- collectionToAdd.retainAll(collectionListIn);
-
- String collectionsCSV = null;
- if (!collectionToAdd.isEmpty()) {
- collectionsCSV = StringUtils.join(collectionToAdd, ',');
- CollectionAdminRequest.CreateAlias aliasCreateRequest = new CollectionAdminRequest.CreateAlias();
- aliasCreateRequest.setAliasName(aliasNameIn);
- aliasCreateRequest.setAliasedCollections(collectionsCSV);
- CollectionAdminResponse createResponse = aliasCreateRequest.process(solrClouldClient);
- if (createResponse.getStatus() != 0) {
- logger.error("Error creating alias. alias=" + aliasNameIn + ", collectionList=" + collectionsCSV +
- ", solrDetail=" + solrDetail + ", response=" + createResponse);
- return 0;
- }
- }
- if ( collectionToAdd.size() == collectionListIn.size()) {
- logger.info("Created alias for all collections. alias=" + aliasNameIn + ", collectionsCSV=" + collectionsCSV +
- ", solrDetail=" + solrDetail);
- } else {
- logger.info("Created alias for " + collectionToAdd.size() + " out of " + collectionListIn.size() + " collections. " +
- "alias=" + aliasNameIn + ", collectionsCSV=" + collectionsCSV + ", solrDetail=" + solrDetail);
- }
- return collectionToAdd.size();
- }
-
- protected void setupCollections(final String splitInterval, final String configName, final int numberOfShards,
- final int replicationFactor, boolean needToPopulateSchemaField) throws Exception {
- if (isZkConnectString) {
- boolean setupStatus = createCollectionsIfNeeded(splitInterval, configName, numberOfShards, replicationFactor);
- logger.info("Setup status for " + collectionName + " is " + setupStatus);
- if (!setupStatus) {
- // Start a background thread to do setup
- Thread setupThread = new Thread("setup_collection_" + collectionName) {
- @Override
- public void run() {
- logger.info("Started monitoring thread to check availability of Solr server. collection=" + collectionName);
- int retryCount = 0;
- while (true) {
- try {
- Thread.sleep(SETUP_RETRY_SECOND * 1000);
- retryCount++;
- boolean setupStatus = createCollectionsIfNeeded(splitInterval, configName, numberOfShards, replicationFactor);
- if (setupStatus) {
- logger.info("Setup for collection " + collectionName + " is successful. Exiting setup retry thread");
- break;
- }
- } catch (InterruptedException sleepInterrupted) {
- logger.info("Sleep interrupted while setting up collection " + collectionName);
- break;
- } catch (Exception e) {
- logger.error("Error setting up collection=" + collectionName, e);
- }
- logger.error("Error setting collection. collection=" + collectionName + ", retryCount=" + retryCount);
- }
- }
- };
- setupThread.setDaemon(true);
- setupThread.start();
- }
- }
-
- if (needToPopulateSchemaField){
- populateSchemaFields();
- }
- }
-
- private boolean createCollectionsIfNeeded(String splitInterval, String configName, int numberOfShards, int replicationFactor) {
- boolean result = false;
- try {
- List<String> allCollectionList = getCollections();
- if (splitInterval.equalsIgnoreCase("none")) {
- result = createCollection(configName, numberOfShards, replicationFactor, allCollectionList);
- } else {
- result = setupCollectionsWithImplicitRouting(configName, numberOfShards, replicationFactor, allCollectionList);
- }
- } catch (Exception ex) {
- logger.error("Error creating collection. collectionName=" + collectionName, ex);
- }
- return result;
- }
-
- private List<String> getCollections() throws SolrServerException,
- IOException {
- try {
- CollectionAdminRequest.List colListReq = new CollectionAdminRequest.List();
- CollectionAdminResponse response = colListReq.process(solrClient);
- if (response.getStatus() != 0) {
- logger.error("Error getting collection list from solr. response=" + response);
- return null;
- }
-
- @SuppressWarnings("unchecked")
- List<String> allCollectionList = (List<String>) response.getResponse().get("collections");
- return allCollectionList;
- } catch (SolrException e) {
- logger.error(e);
- return new ArrayList<String>();
- }
- }
-
- private boolean setupCollectionsWithImplicitRouting(String configName, int numberOfShards, int replicationFactor,
- List<String> allCollectionList) throws Exception {
- logger.info("setupCollectionsWithImplicitRouting(). collectionName=" + collectionName + ", numberOfShards=" + numberOfShards);
-
- // Default is true, because if the collection and shard is already there, then it will return true
- boolean returnValue = true;
-
- List<String> shardsList = new ArrayList<String>();
- for (int i = 0; i < numberOfShards; i++) {
- shardsList.add("shard" + i);
- }
- String shardsListStr = StringUtils.join(shardsList, ',');
-
- // Check if collection is already in zookeeper
- if (!allCollectionList.contains(collectionName)) {
- logger.info("Creating collection " + collectionName + ", shardsList=" + shardsList + ", solrDetail=" + solrDetail);
- CollectionAdminRequest.Create collectionCreateRequest = new CollectionAdminRequest.Create();
- collectionCreateRequest.setCollectionName(collectionName);
- collectionCreateRequest.setRouterName("implicit");
- collectionCreateRequest.setShards(shardsListStr);
- collectionCreateRequest.setNumShards(numberOfShards);
- collectionCreateRequest.setReplicationFactor(replicationFactor);
- collectionCreateRequest.setConfigName(configName);
- collectionCreateRequest.setRouterField(ROUTER_FIELD);
- collectionCreateRequest.setMaxShardsPerNode(replicationFactor * numberOfShards);
-
- CollectionAdminResponse createResponse = collectionCreateRequest.process(solrClient);
- if (createResponse.getStatus() != 0) {
- returnValue = false;
- logger.error("Error creating collection. collectionName=" + collectionName + ", shardsList=" + shardsList +
- ", solrDetail=" + solrDetail + ", response=" + createResponse);
- } else {
- logger.info("Created collection " + collectionName + ", shardsList=" + shardsList + ", solrDetail=" + solrDetail);
- }
- } else {
- logger.info("Collection " + collectionName + " is already there. Will check whether it has the required shards");
- Collection<String> existingShards = getShards();
- for (String shard : shardsList) {
- if (!existingShards.contains(shard)) {
- try {
- logger.info("Going to add Shard " + shard + " to collection " + collectionName);
- CollectionAdminRequest.CreateShard createShardRequest = new CollectionAdminRequest.CreateShard();
- createShardRequest.setCollectionName(collectionName);
- createShardRequest.setShardName(shard);
- CollectionAdminResponse response = createShardRequest.process(solrClient);
- if (response.getStatus() != 0) {
- logger.error("Error creating shard " + shard + " in collection " + collectionName + ", response=" + response +
- ", solrDetail=" + solrDetail);
- returnValue = false;
- break;
- } else {
- logger.info("Successfully created shard " + shard + " in collection " + collectionName);
- }
- } catch (Throwable t) {
- logger.error("Error creating shard " + shard + " in collection " + collectionName + ", solrDetail=" + solrDetail, t);
- returnValue = false;
- break;
- }
- }
- }
- }
- return returnValue;
- }
-
- private Collection<String> getShards() {
- Collection<String> list = new HashSet<String>();
-
- if (solrClouldClient == null) {
- logger.error("getShards(). Only supporting in SolrCloud mode");
- return list;
- }
-
- ZkStateReader reader = solrClouldClient.getZkStateReader();
- Collection<Slice> slices = reader.getClusterState().getSlices(collectionName);
- for (Slice slice : slices) {
- for (Replica replica : slice.getReplicas()) {
- logger.info("colName=" + collectionName + ", slice.name=" + slice.getName() + ", slice.state=" + slice.getState() +
- ", replica.core=" + replica.getStr("core") + ", replica.state=" + replica.getStr("state"));
- list.add(slice.getName());
- }
- }
- return list;
- }
-
- private boolean createCollection(String configName, int numberOfShards, int replicationFactor,
- List<String> allCollectionList) throws SolrServerException, IOException {
- if (allCollectionList.contains(collectionName)) {
- logger.info("Collection " + collectionName + " is already there. Won't create it");
- return true;
- }
-
- logger.info("Creating collection " + collectionName + ", numberOfShards=" + numberOfShards +
- ", replicationFactor=" + replicationFactor + ", solrDetail=" + solrDetail);
-
- CollectionAdminRequest.Create collectionCreateRequest = new CollectionAdminRequest.Create();
- collectionCreateRequest.setCollectionName(collectionName);
- collectionCreateRequest.setNumShards(numberOfShards);
- collectionCreateRequest.setReplicationFactor(replicationFactor);
- collectionCreateRequest.setConfigName(configName);
- collectionCreateRequest.setMaxShardsPerNode(replicationFactor * numberOfShards);
- CollectionAdminResponse createResponse = collectionCreateRequest.process(solrClient);
- if (createResponse.getStatus() != 0) {
- logger.error("Error creating collection. collectionName=" + collectionName + ", solrDetail=" + solrDetail + ", response=" +
- createResponse);
- return false;
- } else {
- logger.info("Created collection " + collectionName + ", numberOfShards=" + numberOfShards +
- ", replicationFactor=" + replicationFactor + ", solrDetail=" + solrDetail);
- return true;
- }
- }
-
public QueryResponse process(SolrQuery solrQuery) throws SolrServerException, IOException {
- if (solrClient != null) {
+ if (getSolrClient() != null) {
String event = solrQuery.get("event");
solrQuery.remove("event");
- QueryResponse queryResponse = solrClient.query(solrQuery, METHOD.POST);
-
+ QueryResponse queryResponse = getSolrClient().query(solrQuery, METHOD.POST);
if (event != null && !"/audit/logs/live/count".equalsIgnoreCase(event)) {
- logPerformance.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Event :- " + event + " SolrQuery :- " +
+ LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Event :- " + event + " SolrQuery :- " +
solrQuery + "\nQuery Time Execution :- " + queryResponse.getQTime() + " Total Time Elapsed is :- " +
queryResponse.getElapsedTime());
}
@@ -452,89 +73,34 @@ public abstract class SolrDaoBase {
}
}
- public UpdateResponse addDocs(SolrInputDocument doc) throws SolrServerException, IOException, SolrException {
- UpdateResponse updateResoponse = solrClient.add(doc);
- logPerformance.info("\n Username :- " + LogSearchContext.getCurrentUsername() +
- " Update Time Execution :- " + updateResoponse.getQTime() + " Total Time Elapsed is :- " + updateResoponse.getElapsedTime());
- solrClient.commit();
- return updateResoponse;
- }
+ @SuppressWarnings("unchecked")
+ public void extractValuesFromBuckets(SimpleOrderedMap<Object> jsonFacetResponse, String outerField, String innerField,
+ List<BarGraphData> histogramData) {
+ NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
+ ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get("buckets");
+ for (Object temp : stackBuckets) {
+ BarGraphData vBarGraphData = new BarGraphData();
- public UpdateResponse removeDoc(String query) throws SolrServerException, IOException, SolrException {
- UpdateResponse updateResoponse = solrClient.deleteByQuery(query);
- solrClient.commit();
- logPerformance.info("\n Username :- " + LogSearchContext.getCurrentUsername() +
- " Remove Time Execution :- " + updateResoponse.getQTime() + " Total Time Elapsed is :- " + updateResoponse.getElapsedTime());
- return updateResoponse;
- }
+ SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
+ String name = ((String) level.getVal(0)).toUpperCase();
+ vBarGraphData.setName(name);
- private void setupSecurity() {
- String jaasFile = solrKerberosConfig.getJaasFile();
- boolean securityEnabled = solrKerberosConfig.isEnabled();
- if (securityEnabled) {
- System.setProperty("java.security.auth.login.config", jaasFile);
- HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
- logger.info("setupSecurity() called for kerberos configuration, jaas file: " + jaasFile);
- }
- }
+ Collection<NameValueData> vNameValues = new ArrayList<>();
+ vBarGraphData.setDataCount(vNameValues);
+ ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level.get(innerField)).get("buckets");
+ for (Object temp1 : levelBuckets) {
+ SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
+ String value = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
- private void populateSchemaFields() {
- if (!populateFieldsThreadActive) {
- populateFieldsThreadActive = true;
- logger.info("Creating thread to populated fields for collection=" + collectionName);
- Thread fieldPopulationThread = new Thread("populated_fields_" + collectionName) {
- @Override
- public void run() {
- logger.info("Started thread to get fields for collection=" + collectionName);
- int retryCount = 0;
- while (true) {
- try {
- Thread.sleep(SETUP_RETRY_SECOND * 1000);
- retryCount++;
- boolean _result = _populateSchemaFields();
- if (_result) {
- logger.info("Populate fields for collection " + collectionName + " is success, Update it after " +
- SETUP_UPDATE_SECOND + " sec");
- Thread.sleep(SETUP_UPDATE_SECOND * 1000);
- }
- } catch (InterruptedException sleepInterrupted) {
- logger.info("Sleep interrupted while populating fields for collection " + collectionName);
- break;
- } catch (Exception ex) {
- logger.error("Error while populating fields for collection " + collectionName + ", retryCount=" + retryCount);
- }
- }
- populateFieldsThreadActive = false;
- logger.info("Exiting thread for populating fields. collection=" + collectionName);
- }
- };
- fieldPopulationThread.setDaemon(true);
- fieldPopulationThread.start();
- }
- }
-
- /**
- * Called from the thread. Don't call this directly
- */
- private boolean _populateSchemaFields() {
- SolrRequest<SchemaResponse> request = new SchemaRequest();
- request.setMethod(METHOD.GET);
- request.setPath("/schema");
- String historyCollection = solrUserConfig.getCollection();
- if (solrClient != null && !collectionName.equals(historyCollection)) {
- NamedList<Object> namedList = null;
- try {
- namedList = solrClient.request(request);
- logger.debug("populateSchemaFields() collection=" + collectionName + ", fields=" + namedList);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error occured while popuplating field. collection=" + collectionName, e);
- }
-
- if (namedList != null) {
- ConfigHelper.extractSchemaFieldsName(namedList.toString(), schemaFieldsNameMap,schemaFieldTypeMap);
- return true;
+ String count = "" + countValue.getVal(1);
+ NameValueData vNameValue = new NameValueData();
+ vNameValue.setName(value);
+ vNameValue.setValue(count);
+ vNameValues.add(vNameValue);
}
+ histogramData.add(vBarGraphData);
}
- return false;
}
+
+ public abstract CloudSolrClient getSolrClient();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
new file mode 100644
index 0000000..b6764d0
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.dao;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.MessageEnums;
+import org.apache.ambari.logsearch.conf.SolrPropsConfig;
+import org.apache.ambari.logsearch.conf.SolrUserPropsConfig;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.schema.SchemaRequest;
+import org.apache.solr.client.solrj.response.schema.SchemaResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+@Scope(value = "prototype")
+public class SolrSchemaFieldDao {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SolrSchemaFieldDao.class);
+
+ private static final int SETUP_RETRY_SECOND = 30;
+ private static final int SETUP_UPDATE_SECOND = 10 * 60; // 10 min
+
+ private boolean populateFieldsThreadActive = false;
+
+ @Inject
+ private SolrUserPropsConfig solrUserPropsConfig;
+
+ public void populateSchemaFields(final CloudSolrClient solrClient, final SolrPropsConfig solrPropsConfig,
+ final SolrDaoBase solrDao) {
+ if (!populateFieldsThreadActive) {
+ populateFieldsThreadActive = true;
+ LOG.info("Creating thread to populated fields for collection=" + solrPropsConfig.getCollection());
+ Thread fieldPopulationThread = new Thread("populated_fields_" + solrPropsConfig.getCollection()) {
+ @Override
+ public void run() {
+ LOG.info("Started thread to get fields for collection=" + solrPropsConfig.getCollection());
+ int retryCount = 0;
+ while (true) {
+ try {
+ Thread.sleep(SETUP_RETRY_SECOND * 1000);
+ retryCount++;
+ boolean _result = _populateSchemaFields(solrClient, solrPropsConfig, solrDao);
+ if (_result) {
+ LOG.info("Populate fields for collection " + solrPropsConfig.getCollection() + " is success, Update it after " +
+ SETUP_UPDATE_SECOND + " sec");
+ Thread.sleep(SETUP_UPDATE_SECOND * 1000);
+ }
+ } catch (InterruptedException sleepInterrupted) {
+ LOG.info("Sleep interrupted while populating fields for collection " + solrPropsConfig.getCollection());
+ break;
+ } catch (Exception ex) {
+ LOG.error("Error while populating fields for collection " + solrPropsConfig.getCollection() + ", retryCount=" + retryCount);
+ }
+ }
+ populateFieldsThreadActive = false;
+ LOG.info("Exiting thread for populating fields. collection=" + solrPropsConfig.getCollection());
+ }
+ };
+ fieldPopulationThread.setDaemon(true);
+ fieldPopulationThread.start();
+ }
+ }
+
+ /**
+ * Called from the thread. Don't call this directly
+ */
+ private boolean _populateSchemaFields(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig, SolrDaoBase solrDao) {
+ SolrRequest<SchemaResponse> request = new SchemaRequest();
+ request.setMethod(SolrRequest.METHOD.GET);
+ request.setPath("/schema");
+ String historyCollection = solrUserPropsConfig.getCollection();
+ if (solrClient != null && !solrPropsConfig.getCollection().equals(historyCollection)) {
+ NamedList<Object> namedList = null;
+ try {
+ namedList = solrClient.request(request);
+ LOG.debug("populateSchemaFields() collection=" + solrPropsConfig.getCollection() + ", fields=" + namedList);
+ } catch (SolrException | SolrServerException | IOException e) {
+ LOG.error("Error occured while popuplating field. collection=" + solrPropsConfig.getCollection(), e);
+ }
+
+ if (namedList != null) {
+ extractSchemaFieldsName(namedList.toString(), solrDao.schemaFieldNameMap, solrDao.schemaFieldTypeMap);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void extractSchemaFieldsName(String responseString,
+ final Map<String, String> schemaFieldsNameMap,
+ final Map<String, String> schemaFieldTypeMap) {
+ try {
+ JSONObject jsonObject = new JSONObject(responseString);
+ JSONObject schemajsonObject = jsonObject.getJSONObject("schema");
+ JSONArray jsonArrayList = schemajsonObject.getJSONArray("fields");
+ JSONArray fieldTypeJsonArray = schemajsonObject
+ .getJSONArray("fieldTypes");
+ if (jsonArrayList == null) {
+ return;
+ }
+ if (fieldTypeJsonArray == null) {
+ return;
+ }
+ HashMap<String, String> _schemaFieldTypeMap = new HashMap<>();
+ HashMap<String, String> _schemaFieldsNameMap = new HashMap<String, String>();
+ for (int i = 0; i < fieldTypeJsonArray.length(); i++) {
+ JSONObject typeObject = fieldTypeJsonArray.getJSONObject(i);
+ String name = typeObject.getString("name");
+ String fieldTypeJson = typeObject.toString();
+ _schemaFieldTypeMap.put(name, fieldTypeJson);
+ }
+ for (int i = 0; i < jsonArrayList.length(); i++) {
+ JSONObject explrObject = jsonArrayList.getJSONObject(i);
+ String name = explrObject.getString("name");
+ String type = explrObject.getString("type");
+ if (!name.contains("@") && !name.startsWith("_") && !name.contains("_md5") && !name.contains("_ms") &&
+ !name.contains(LogSearchConstants.NGRAM_SUFFIX) && !name.contains("tags") && !name.contains("_str")) {
+ _schemaFieldsNameMap.put(name, type);
+ }
+ }
+ schemaFieldsNameMap.clear();
+ schemaFieldTypeMap.clear();
+ schemaFieldsNameMap.putAll(_schemaFieldsNameMap);
+ schemaFieldTypeMap.putAll(_schemaFieldTypeMap);
+ } catch (Exception e) {
+ LOG.error(e + "Credentials not specified in logsearch.properties " + MessageEnums.ERROR_SYSTEM);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
index a9fb8d2..88c4577 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
@@ -29,12 +29,15 @@ import java.util.Scanner;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import org.apache.ambari.logsearch.conf.SolrUserConfig;
+import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.conf.SolrUserPropsConfig;
import org.apache.ambari.logsearch.view.VLogfeederFilterWrapper;
import org.apache.ambari.logsearch.common.LogSearchConstants;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
@@ -47,38 +50,55 @@ import com.google.gson.JsonParseException;
import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
import org.apache.ambari.logsearch.util.JSONUtil;
import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@Component
public class UserConfigSolrDao extends SolrDaoBase {
- private static final Logger logger = Logger.getLogger(UserConfigSolrDao.class);
+ private static final Logger LOG = Logger.getLogger(UserConfigSolrDao.class);
+
+ private static final Logger LOG_PERFORMANCE = Logger.getLogger("org.apache.ambari.logsearch.performance");
+
+ @Inject
+ private SolrUserPropsConfig solrUserConfig;
+
+ @Inject
+ private SolrCollectionDao solrCollectionDao;
+
+ @Inject
+ private SolrSchemaFieldDao solrSchemaFieldDao;
@Inject
- private SolrUserConfig solrUserConfig;
+ @Qualifier("userConfigSolrTemplate")
+ private SolrTemplate userConfigSolrTemplate;
public UserConfigSolrDao() {
super(LogType.SERVICE);
}
+ @Override
+ public CloudSolrClient getSolrClient() {
+ return (CloudSolrClient) userConfigSolrTemplate.getSolrClient();
+ }
+
+
@PostConstruct
public void postConstructor() {
String solrUrl = solrUserConfig.getSolrUrl();
String zkConnectString = solrUserConfig.getZkConnectString();
String collection = solrUserConfig.getCollection();
- String configName = solrUserConfig.getConfigName();
- int replicationFactor = solrUserConfig.getReplicationFactor();
- String splitInterval = solrUserConfig.getSplitInterval();
- int numberOfShards = solrUserConfig.getNumberOfShards();
try {
- connectToSolr(solrUrl, zkConnectString, collection);
- setupCollections(splitInterval, configName, numberOfShards, replicationFactor, true);
+ solrCollectionDao.checkSolrStatus(getSolrClient());
+ solrCollectionDao.setupCollections(getSolrClient(), solrUserConfig);
+ solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrUserConfig, this);
intializeLogFeederFilter();
} catch (Exception e) {
- logger.error("error while connecting to Solr for history logs : solrUrl=" + solrUrl + ", zkConnectString=" + zkConnectString +
+ LOG.error("error while connecting to Solr for history logs : solrUrl=" + solrUrl + ", zkConnectString=" + zkConnectString +
", collection=" + collection, e);
}
}
@@ -87,7 +107,7 @@ public class UserConfigSolrDao extends SolrDaoBase {
try {
getUserFilter();
} catch (SolrServerException | IOException e) {
- logger.error("not able to save logfeeder filter while initialization", e);
+ LOG.error("not able to save logfeeder filter while initialization", e);
}
}
@@ -107,6 +127,22 @@ public class UserConfigSolrDao extends SolrDaoBase {
removeDoc("id:" + id);
}
+ public UpdateResponse addDocs(SolrInputDocument doc) throws SolrServerException, IOException, SolrException {
+ UpdateResponse updateResoponse = getSolrClient().add(doc);
+ LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() +
+ " Update Time Execution :- " + updateResoponse.getQTime() + " Total Time Elapsed is :- " + updateResoponse.getElapsedTime());
+ getSolrClient().commit();
+ return updateResoponse;
+ }
+
+ public UpdateResponse removeDoc(String query) throws SolrServerException, IOException, SolrException {
+ UpdateResponse updateResoponse = getSolrClient().deleteByQuery(query);
+ getSolrClient().commit();
+ LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() +
+ " Remove Time Execution :- " + updateResoponse.getQTime() + " Total Time Elapsed is :- " + updateResoponse.getElapsedTime());
+ return updateResoponse;
+ }
+
@SuppressWarnings("unchecked")
public VLogfeederFilterWrapper getUserFilter() throws SolrServerException, IOException {
@@ -158,7 +194,7 @@ public class UserConfigSolrDao extends SolrDaoBase {
saveUserFilter(logfeederFilterWrapper);
} catch (JsonParseException | JSONException je) {
- logger.error("Error parsing JSON. key=" + key + ", componentArray=" + componentArray, je);
+ LOG.error("Error parsing JSON. key=" + key + ", componentArray=" + componentArray, je);
logfeederFilterWrapper = new VLogfeederFilterWrapper();
}
}
@@ -182,7 +218,7 @@ public class UserConfigSolrDao extends SolrDaoBase {
scanner.close();
} catch (IOException e) {
- logger.error("Unable to read HadoopServiceConfig.json", e);
+ LOG.error("Unable to read HadoopServiceConfig.json", e);
}
String hadoopServiceConfig = result.toString();
@@ -191,5 +227,4 @@ public class UserConfigSolrDao extends SolrDaoBase {
}
return null;
}
-
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java
index 4ca9df6..0810571 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java
@@ -26,17 +26,15 @@ import java.util.HashMap;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import org.apache.ambari.logsearch.conf.AuthConfig;
+import org.apache.ambari.logsearch.conf.AuthPropsConfig;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Repository;
-import org.apache.ambari.logsearch.common.PropertiesHelper;
import org.apache.ambari.logsearch.util.CommonUtil;
import org.apache.ambari.logsearch.util.FileUtil;
import org.apache.ambari.logsearch.util.JSONUtil;
import org.apache.ambari.logsearch.web.model.Privilege;
import org.apache.ambari.logsearch.web.model.Role;
import org.apache.ambari.logsearch.web.model.User;
-import org.apache.ambari.logsearch.web.security.LogsearchFileAuthenticationProvider;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.lang.StringUtils;
@@ -52,16 +50,16 @@ public class UserDao {
private static final String NAME = "name";
@Inject
- private AuthConfig authConfig;
+ private AuthPropsConfig authPropsConfig;
private ArrayList<HashMap<String, String>> userList = null;
@SuppressWarnings("unchecked")
@PostConstruct
public void initialization() {
- if (authConfig.isAuthFileEnabled()) {
+ if (authPropsConfig.isAuthFileEnabled()) {
try {
- String userPassJsonFileName = authConfig.getCredentialsFile();
+ String userPassJsonFileName = authPropsConfig.getCredentialsFile();
logger.info("USER PASS JSON file NAME:" + userPassJsonFileName);
File jsonFile = FileUtil.getFileFromClasspath(userPassJsonFileName);
if (jsonFile == null || !jsonFile.exists()) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
index 8e14452..0df2ca3 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
@@ -39,9 +39,7 @@ public class DocConstants {
public static final String PAGE_SIZE_D = "Page size of the results";
public static final String UNIT_D = "Aggregate the data with time gap as unit i.e 1MINUTE";
public static final String QUERY_D = "not required";
- public static final String COLUMN_QUERY_D = "not required";
public static final String I_MESSAGE_D = "Include query which will query against message column";
- public static final String G_E_MESSAGE_D = "not required";
public static final String E_MESSAGE_D = "Exclude query which will query against message column";
public static final String IS_LAST_PAGE_D = "Show last page (true/false)";
public static final String FIELD_D = "Get values for particular field";
@@ -64,17 +62,13 @@ public class DocConstants {
public class ServiceDescriptions {
public static final String LEVEL_D = "filter for log level";
- public static final String ADVANCED_SEARCH_D = "not required";
public static final String BUNDLE_ID = "filter for host";
- public static final String TREE_PARAMS_D = "Host hierarchy shown on UI, filtering there is supported by this param";
public static final String FILE_NAME_D = "File name filter which is supported from browser url";
- public static final String HOST_NAME_D = "Host name filter which is supported from browser url";
public static final String DATE_RANGE_LABEL_D = "Date range label (e.g.: Today)";
+ public static final String HOST_NAME_D = "Host name filter which is supported from browser url";
public static final String COMPONENT_NAME_D = "Component name filter which is supported from browser url";
public static final String FIND_D = "Finding particular text on subsequent pages in case of table view with pagination";
public static final String ID_D = "Log id value for traversing to that particular record with that log id";
- public static final String HOST_D = "filter for host";
- public static final String COMPONENT_D = "filter for component";
public static final String KEYWORD_TYPE_D = "Serching the find param value in previous or next in paginated table";
public static final String TOKEN_D = "unique number used along with FIND_D. The request can be canceled using this token";
public static final String SOURCE_LOG_ID_D = "fetch the record set having that log Id";
@@ -106,19 +100,6 @@ public class DocConstants {
public static final String GET_HADOOP_SERVICE_CONFIG_JSON_OD = "Get the json having meta data of services supported by logsearch";
}
-
- public class LogFileDescriptions {
- public static final String HOST_D = "not required";
- public static final String COMPONENT_D = "not required";
- public static final String LOG_TYPE_D = "not required";
- public static final String TAIL_SIZE_D = "not required";
- }
-
- public class LogFileOperationDescriptions {
- public static final String SEARCH_LOG_FILES_OD = "not required";
- public static final String GET_LOG_FILE_TAIL_OD = "not required";
- }
-
public class PublicOperationDescriptions {
public static final String OBTAIN_GENERAL_CONFIG_OD = "Obtain general config";
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
index bc377e5..287ff6c 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
@@ -63,7 +63,7 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
String from = (String) searchCriteria.getParamValue("from");
String to = (String) searchCriteria.getParamValue("to");
String unit = (String) searchCriteria.getParamValue("unit");
- String typeXAxis = solrDaoBase.schemaFieldsNameMap.get(xAxisField);
+ String typeXAxis = solrDaoBase.schemaFieldNameMap.get(xAxisField);
typeXAxis = (StringUtils.isBlank(typeXAxis)) ? "string" : typeXAxis;
// Y axis credentials
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
index c64cf71..52482c2 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
@@ -28,17 +28,14 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import org.apache.ambari.logsearch.common.ConfigHelper;
import org.apache.ambari.logsearch.common.LogSearchConstants;
import org.apache.ambari.logsearch.common.ManageStartEndTime;
import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.conf.SolrAuditLogConfig;
+import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
import org.apache.ambari.logsearch.dao.AuditSolrDao;
import org.apache.ambari.logsearch.graph.GraphDataGenerator;
import org.apache.ambari.logsearch.model.response.AuditLogResponse;
@@ -63,7 +60,6 @@ import org.apache.ambari.logsearch.util.RESTErrorUtil;
import org.apache.ambari.logsearch.util.SolrUtil;
import org.apache.ambari.logsearch.view.VResponse;
import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
@@ -85,7 +81,7 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
@Inject
private GraphDataGenerator graphDataGenerator;
@Inject
- private SolrAuditLogConfig solrAuditLogConfig;
+ private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
public AuditLogResponse getLogs(AuditLogSearchCriteria searchCriteria) {
Boolean isLastPage = searchCriteria.isLastPage();
@@ -159,29 +155,7 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_COMPONENT,
LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
- try {
- SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
- SolrUtil.setRowCount(solrQuery, 0);
- QueryResponse response = auditSolrDao.process(solrQuery);
- if (response == null) {
- return dataList;
- }
- SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-
- if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
- return dataList;
- }
-
- extractValuesFromBucket(jsonFacetResponse, "x", "y", histogramData);
-
- dataList.setGraphData(histogramData);
- return dataList;
-
- } catch (SolrServerException | SolrException | IOException e) {
- logger.error(e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-
- }
+ return getGraphResponse(dataList, solrQuery, histogramData, jsonHistogramQuery);
}
@SuppressWarnings({"unchecked", "rawtypes"})
@@ -316,49 +290,11 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_REQUEST_USER,
LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
- try {
- SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
- SolrUtil.setRowCount(solrQuery, 0);
- QueryResponse response = auditSolrDao.process(solrQuery);
- if (response == null) {
- return dataList;
- }
- SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-
- if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
- return dataList;
- }
- extractValuesFromBucket(jsonFacetResponse, "x", "y", histogramData);
-
- dataList.setGraphData(histogramData);
- return dataList;
-
- } catch (SolrException | IOException | SolrServerException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
-
+ return getGraphResponse(dataList, solrQuery, histogramData, jsonHistogramQuery);
}
public String getAuditLogsSchemaFieldsName() {
- String excludeArray[] = Arrays.copyOf(solrAuditLogConfig.getExcludeColumnList().toArray(),
- solrAuditLogConfig.getExcludeColumnList().size(), String[].class);
- List<String> fieldNames = new ArrayList<String>();
- HashMap<String, String> uiFieldColumnMapping = new HashMap<String, String>();
- ConfigHelper.getSchemaFieldsName(excludeArray, fieldNames, auditSolrDao);
-
- for (String fieldName : fieldNames) {
- String uiField = solrAuditLogConfig.getSolrAndUiColumns().get(fieldName + LogSearchConstants.SOLR_SUFFIX);
- if (uiField == null) {
- uiFieldColumnMapping.put(fieldName, fieldName);
- } else {
- uiFieldColumnMapping.put(fieldName, uiField);
- }
- }
-
- uiFieldColumnMapping = BizUtil.sortHashMapByValues(uiFieldColumnMapping);
- return convertObjToString(uiFieldColumnMapping);
-
+ return convertObjToString(auditSolrDao.schemaFieldNameMap);
}
public BarGraphDataListResponse getAnyGraphData(AnyGraphSearchCriteria searchCriteria) {
@@ -372,35 +308,6 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
}
- @SuppressWarnings("unchecked")
- private void extractValuesFromBucket(SimpleOrderedMap<Object> jsonFacetResponse, String outerField, String innerField,
- List<BarGraphData> histogramData) {
- NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
- ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get("buckets");
- for (Object temp : stackBuckets) {
- BarGraphData vBarGraphData = new BarGraphData();
-
- SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
- String name = ((String) level.getVal(0)).toUpperCase();
- vBarGraphData.setName(name);
-
- Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
- vBarGraphData.setDataCount(vNameValues);
- ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level.get(innerField)).get("buckets");
- for (Object temp1 : levelBuckets) {
- SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
- String value = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
-
- String count = "" + countValue.getVal(1);
- NameValueData vNameValue = new NameValueData();
- vNameValue.setName(value);
- vNameValue.setValue(count);
- vNameValues.add(vNameValue);
- }
- histogramData.add(vBarGraphData);
- }
- }
-
@SuppressWarnings({"unchecked"})
public Response exportUserTableToTextFile(UserExportSearchCriteria searchCriteria) {
String jsonUserQuery =
@@ -417,6 +324,7 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
SolrUtil.setRowCount(solrQuery, 0);
String dataFormat = searchCriteria.getFormat();
+
FileOutputStream fis = null;
try {
QueryResponse queryResponse = auditSolrDao.process(solrQuery);
@@ -458,15 +366,7 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
data += addBlank(userName);
Collection<NameValueData> vnameValueList = graphData.getDataCount();
- int count = 0;
- String blank = "";
- for (NameValueData vNameValue : vnameValueList) {
- data += blank + vNameValue.getName() + " " + vNameValue.getValue() + "\n";
- if (count == 0)
- blank = addBlank(blank);
- count++;
-
- }
+ data = appendNameValueData(data, vnameValueList);
while (largeUserName.length() > 0) {
data += largeUserName.substring(0, 45) + "\n";
}
@@ -490,14 +390,7 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
//resourceName = resourceName.replaceAll("(.{45})", resourceName.substring(0, 45)+"\n");
data += addBlank(resourceName);
Collection<NameValueData> vnameValueList = graphData.getDataCount();
- int count = 0;
- String blank = "";
- for (NameValueData vNameValue : vnameValueList) {
- data += blank + vNameValue.getName() + " " + vNameValue.getValue() + "\n";
- if (count == 0)
- blank = addBlank(blank);
- count++;
- }
+ data = appendNameValueData(data, vnameValueList);
String tempLargeResourceName = largeResourceName;
while (largeResourceName.length() > 45) {
largeResourceName = tempLargeResourceName.substring(0, 45);
@@ -539,6 +432,45 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
}
}
+ private BarGraphDataListResponse getGraphResponse(BarGraphDataListResponse dataList, SolrQuery solrQuery,
+ List<BarGraphData> histogramData, String jsonHistogramQuery) {
+ try {
+ SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
+ SolrUtil.setRowCount(solrQuery, 0);
+ QueryResponse response = auditSolrDao.process(solrQuery);
+ if (response == null) {
+ return dataList;
+ }
+ SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
+
+ if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
+ return dataList;
+ }
+
+ auditSolrDao.extractValuesFromBuckets(jsonFacetResponse, "x", "y", histogramData);
+
+ dataList.setGraphData(histogramData);
+ return dataList;
+
+ } catch (SolrServerException | SolrException | IOException e) {
+ logger.error(e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+
+ }
+ }
+
+ private String appendNameValueData(String data, Collection<NameValueData> vnameValueList) {
+ int count = 0;
+ String blank = "";
+ for (NameValueData vNameValue : vnameValueList) {
+ data += blank + vNameValue.getName() + " " + vNameValue.getValue() + "\n";
+ if (count == 0)
+ blank = addBlank(blank);
+ count++;
+ }
+ return data;
+ }
+
private String addBlank(String field) {
int blanks = 50;
int strSize = field.length();
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileManager.java
deleted file mode 100644
index 405eaef..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileManager.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.manager;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.model.response.LogFileData;
-import org.apache.ambari.logsearch.model.response.LogFileDataListResponse;
-import org.apache.ambari.logsearch.model.response.LogListResponse;
-import org.apache.ambari.logsearch.model.response.ServiceLogData;
-import org.apache.ambari.logsearch.model.response.ServiceLogResponse;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
-import org.apache.ambari.logsearch.dao.AuditSolrDao;
-import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.FacetField;
-import org.apache.solr.client.solrj.response.FacetField.Count;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.SolrException;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-
-
-@Component
-public class LogFileManager extends ManagerBase<ServiceLogData, ServiceLogResponse> {
-
- private static final Logger logger = Logger.getLogger(LogFileManager.class);
-
- @Inject
- private ServiceLogsSolrDao serviceLogsSolrDao;
- @Inject
- private AuditSolrDao auditSolrDao;
-
- public LogFileDataListResponse searchLogFiles(SearchCriteria searchCriteria) {
- LogFileDataListResponse logFileList = new LogFileDataListResponse();
- List<LogFileData> logFiles = new ArrayList<LogFileData>();
- String componentName = (String) searchCriteria.getParamValue("component");
- String host = (String) searchCriteria.getParamValue("host");
- int minCount = 1;// to remove zero count facet
- SolrQuery solrQuery = new SolrQuery();
- SolrUtil.setMainQuery(solrQuery, null);
- SolrUtil.setFacetFieldWithMincount(solrQuery, LogSearchConstants.SOLR_PATH, minCount);
- // adding filter
- queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_COMPONENT, componentName);
- queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_HOST, host);
- try {
- String logType = (String) searchCriteria.getParamValue("logType");
- if (StringUtils.isBlank(logType)) {
- logType = LogType.SERVICE.name();// default is service Log
- }
- SolrDaoBase daoMgr = null;
- if (logType.equalsIgnoreCase(LogType.SERVICE.name())) {
- daoMgr = serviceLogsSolrDao;
- } else if (logType.equalsIgnoreCase(LogType.AUDIT.name())) {
- daoMgr = auditSolrDao;
- } else {
- throw RESTErrorUtil.createRESTException(logType + " is not a valid logType", MessageEnums.INVALID_INPUT_DATA);
- }
- QueryResponse queryResponse = daoMgr.process(solrQuery);
- if (queryResponse.getFacetField(LogSearchConstants.SOLR_PATH) != null) {
- FacetField queryFacetField = queryResponse.getFacetField(LogSearchConstants.SOLR_PATH);
- if (queryFacetField != null) {
- List<Count> countList = queryFacetField.getValues();
- for (Count count : countList) {
- LogFileData vLogFile = new LogFileData();
- String filePath = count.getName();
- String fileName = FilenameUtils.getName(filePath);
- vLogFile.setPath(filePath);
- vLogFile.setName(fileName);
- logFiles.add(vLogFile);
- }
- }
- }
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error in solr query :" + e.getLocalizedMessage() + "\n Query :" + solrQuery.toQueryString(), e.getCause());
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- logFileList.setLogFiles(logFiles);
-
- return logFileList;
- }
-
- public LogListResponse getLogFileTail(SearchCriteria searchCriteria) {
- String host = (String) searchCriteria.getParamValue("host");
- String logFile = (String) searchCriteria.getParamValue("name");
- String component = (String) searchCriteria.getParamValue("component");
- String tailSize = (String) searchCriteria.getParamValue("tailSize");
- if (StringUtils.isBlank(host)) {
- throw RESTErrorUtil.createRESTException("missing Host Name", MessageEnums.ERROR_SYSTEM);
- }
- tailSize = (StringUtils.isBlank(tailSize)) ? "10" : tailSize;
- SolrQuery logFileTailQuery = new SolrQuery();
- try {
- int tail = Integer.parseInt(tailSize);
- tail = tail > 100 ? 100 : tail;
- SolrUtil.setMainQuery(logFileTailQuery, null);
- queryGenerator.setSingleIncludeFilter(logFileTailQuery, LogSearchConstants.SOLR_HOST, host);
- if (!StringUtils.isBlank(logFile)) {
- queryGenerator.setSingleIncludeFilter(logFileTailQuery, LogSearchConstants.SOLR_PATH, SolrUtil.makeSolrSearchString(logFile));
- } else if (!StringUtils.isBlank(component)) {
- queryGenerator.setSingleIncludeFilter(logFileTailQuery, LogSearchConstants.SOLR_COMPONENT, component);
- } else {
- throw RESTErrorUtil.createRESTException("component or logfile parameter must be present", MessageEnums.ERROR_SYSTEM);
- }
-
- SolrUtil.setRowCount(logFileTailQuery, tail);
- queryGenerator.setSortOrderDefaultServiceLog(logFileTailQuery, new SearchCriteria());
- return getLogAsPaginationProvided(logFileTailQuery, serviceLogsSolrDao);
-
- } catch (NumberFormatException ne) {
-
- throw RESTErrorUtil.createRESTException(ne.getMessage(),
- MessageEnums.ERROR_SYSTEM);
-
- }
- }
-
- @Override
- protected List<ServiceLogData> convertToSolrBeans(QueryResponse response) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected ServiceLogResponse createLogSearchResponse() {
- throw new UnsupportedOperationException();
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3013589a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
index 3ac2be6..82817d6 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
@@ -22,7 +22,7 @@ package org.apache.ambari.logsearch.manager;
import java.util.ArrayList;
import java.util.List;
-import org.apache.ambari.logsearch.conf.AuthConfig;
+import org.apache.ambari.logsearch.conf.AuthPropsConfig;
import org.apache.ambari.logsearch.model.response.NameValueData;
import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
import org.springframework.stereotype.Component;
@@ -33,14 +33,14 @@ import javax.inject.Inject;
public class PublicManager extends JsonManagerBase {
@Inject
- private AuthConfig authConfig;
+ private AuthPropsConfig authPropsConfig;
public String getGeneralConfig() {
NameValueDataListResponse nameValueList = new NameValueDataListResponse();
List<NameValueData> nameValues = new ArrayList<>();
NameValueData nameValue = new NameValueData();
nameValue.setName("simpleAuth");
- nameValue.setValue("" + authConfig.isAuthSimpleEnabled());
+ nameValue.setValue("" + authPropsConfig.isAuthSimpleEnabled());
nameValues.add(nameValue);
nameValueList.setvNameValues(nameValues);
return convertObjToString(nameValueList);