diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/LogServlet.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/LogServlet.java index d889344d8a1..ad6ba8c0f56 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/LogServlet.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/LogServlet.java @@ -44,7 +44,9 @@ import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.StreamingOutput; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -287,16 +289,39 @@ public Response getContainerLogsInfo(HttpServletRequest req, if (query != null && !query.isEmpty()) { resURI += "?" + query; } - Response.ResponseBuilder response = Response.status( - HttpServletResponse.SC_TEMPORARY_REDIRECT); - response.header("Location", resURI); - return response.build(); + return createLocationResponse(resURI, createEmptyLogsInfo()); } else { throw new NotFoundException( "The application is not at Running or Finished State."); } } + /** + * Creates a response with empty payload and a location header to preserve + * API compatibility + * + * @param uri redirection url + * @param emptyPayload a payload that is discarded + * @return a response with empty payload + */ + private static Response createLocationResponse( + String uri, T emptyPayload) { + + Response.ResponseBuilder response = Response.status( + HttpServletResponse.SC_PARTIAL_CONTENT).entity(emptyPayload); + response.header("Location", uri); + response.header("Access-Control-Expose-Headers", "Location"); + return response.build(); + } + + private static GenericEntity> createEmptyLogsInfo() { + return new GenericEntity>( + Collections.EMPTY_LIST, List.class); + } + + private static StreamingOutput createEmptyStream() { + return outputStream -> outputStream.write("".getBytes()); + } /** * Returns an aggregated log file belonging to a container. @@ -388,10 +413,7 @@ public Response getLogFile(HttpServletRequest req, String containerIdStr, if (query != null && !query.isEmpty()) { resURI += "?" + query; } - Response.ResponseBuilder response = Response.status( - HttpServletResponse.SC_TEMPORARY_REDIRECT); - response.header("Location", resURI); - return response.build(); + return createLocationResponse(resURI, createEmptyStream()); } else { return LogWebServiceUtils.createBadResponse(Status.NOT_FOUND, "The application is not at Running or Finished State."); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-jhs-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-jhs-log.js index 3bb241317c2..d5b3ee371b5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-jhs-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-jhs-log.js @@ -43,6 +43,14 @@ export default RESTAbstractAdapter.extend({ return url; }, + handleResponse(status, headers, payload, requestData) { + if (headers['location'] !== undefined && headers['location'] !== null) { + return { redirectedUrl: headers.location, data: "" } + } else { + return { data: payload } + } + }, + /** * Override options so that result is not expected to be JSON */ diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-jhs-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-jhs-redirect-log.js new file mode 100644 index 00000000000..dcd1685547a --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-jhs-redirect-log.js @@ -0,0 +1,60 @@ +/** + * 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. + */ + +import Ember from 'ember'; +import Converter from 'yarn-ui/utils/converter'; +import RESTAbstractAdapter from './restabstract'; + +/** + * REST URL's response when fetching container logs will be + * in plain text format and not JSON. + */ +export default RESTAbstractAdapter.extend({ + headers: { + Accept: 'text/plain' + }, + + urlForFindRecord(id/*, modelName, snapshot*/) { + var splits = Converter.splitForAppLogs(id); + var url = splits[0]; + Ember.Logger.info('The URL for getting the log: ' + url); + return url; + }, + + /** + * Override options so that result is not expected to be JSON + */ + ajaxOptions: function (url, type, options) { + var hash = options || {}; + hash.url = url; + hash.type = type; + // Make sure jQuery does not try to convert response to JSON. + hash.dataType = 'text'; + hash.context = this; + + var headers = Ember.get(this, 'headers'); + if (headers !== undefined) { + hash.beforeSend = function (xhr) { + Object.keys(headers).forEach(function (key) { + return xhr.setRequestHeader(key, headers[key]); + }); + }; + } + return hash; + } +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-log.js index 07bf6130494..297b40180e3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-log.js @@ -47,6 +47,14 @@ export default RESTAbstractAdapter.extend({ return url; }, + handleResponse(status, headers, payload, requestData) { + if (headers['location'] !== undefined && headers['location'] !== null) { + return { redirectedUrl: headers.location, data: "" } + } else { + return { data: payload } + } + }, + /** * Override options so that result is not expected to be JSON */ diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-redirect-log.js new file mode 100644 index 00000000000..4ee16cf09a1 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app-redirect-log.js @@ -0,0 +1,61 @@ +/** + * 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. + */ + +import Ember from 'ember'; +import Converter from 'yarn-ui/utils/converter'; +import RESTAbstractAdapter from './restabstract'; + +/** + * REST URL's response when fetching container logs will be + * in plain text format and not JSON. + */ +export default RESTAbstractAdapter.extend({ + + headers: { + Accept: 'text/plain' + }, + + urlForFindRecord(id/*, modelName, snapshot*/) { + var splits = Converter.splitForAppLogs(id); + var url = splits[0]; + Ember.Logger.info('The URL for getting the log: ' + url); + return url; + }, + + /** + * Override options so that result is not expected to be JSON + */ + ajaxOptions: function (url, type, options) { + var hash = options || {}; + hash.url = url; + hash.type = type; + // Make sure jQuery does not try to convert response to JSON. + hash.dataType = 'text'; + hash.context = this; + + var headers = Ember.get(this, 'headers'); + if (headers !== undefined) { + hash.beforeSend = function (xhr) { + Object.keys(headers).forEach(function (key) { + return xhr.setRequestHeader(key, headers[key]); + }); + }; + } + return hash; + } +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-jhs-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-jhs-log.js index b0c27849231..d05acf878d9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-jhs-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-jhs-log.js @@ -18,6 +18,20 @@ import AbstractAdapter from './abstract'; + +function createEmptyContainerLogInfo(location) { + return { + containerLogsInfo: { + containerLogInfo: [{ + fileName: "", + fileSize: "", + lastModifiedTime: "", + redirectedUrl: location + }] + } + }; +} + export default AbstractAdapter.extend({ address: "jhsAddress", restNameSpace: "jhs", @@ -28,5 +42,14 @@ export default AbstractAdapter.extend({ var containerId = query['containerId']; delete query.containerId; return url + '/containers/' + containerId + '/logs'; + }, + + handleResponse(status, headers, payload, requestData) { + if (headers['location'] !== undefined && headers['location'] !== null) { + return createEmptyContainerLogInfo(headers['location']); + } else { + return payload; + } } + }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-jhs-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-jhs-redirect-log.js new file mode 100644 index 00000000000..b3bb66e8a47 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-jhs-redirect-log.js @@ -0,0 +1,30 @@ +/** + * 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. + */ + +import AbstractAdapter from './abstract'; + +export default AbstractAdapter.extend({ + address: "jhsAddress", + restNameSpace: "jhs", + serverName: "JHS", + + urlForQuery(url/*, modelName*/) { + return url; + } + +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-log.js index 66f34061546..20c0bdc0a66 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-log.js @@ -18,6 +18,19 @@ import AbstractAdapter from './abstract'; +function createEmptyContainerLogInfo(location) { + return { + containerLogsInfo: { + containerLogInfo: [{ + fileName: "", + fileSize: "", + lastModifiedTime: "", + redirectedUrl: location + }] + } + }; +} + export default AbstractAdapter.extend({ address: "timelineWebAddress", restNameSpace: "timelineV2Log", @@ -29,5 +42,14 @@ export default AbstractAdapter.extend({ var clusterId = this.get("env.app.clusterId"); delete query.containerId; return url + '/containers/' + containerId + '/logs' + '?clusterid=' + clusterId; + }, + + handleResponse(status, headers, payload, requestData) { + if (headers['location'] !== undefined && headers['location'] !== null) { + return createEmptyContainerLogInfo(headers['location']); + } else { + return payload; + } } + }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-redirect-log.js new file mode 100644 index 00000000000..7c2b81e025b --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-redirect-log.js @@ -0,0 +1,30 @@ +/** + * 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. + */ + +import AbstractAdapter from './abstract'; + +export default AbstractAdapter.extend({ + address: "timelineWebAddress", + restNameSpace: "timelineV2Log", + serverName: "ATS", + + urlForQuery(url/*, modelName*/) { + return url; + } + +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app/logs.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app/logs.js index b92890a42a8..a84394bb297 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app/logs.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app/logs.js @@ -235,26 +235,54 @@ export default Ember.Controller.extend({ fetchLogFilesForContainerId(containerId) { let queryName = this.fallbackToJHS ? "yarn-jhs-log" : "yarn-log"; + let redirectQuery = queryName === "yarn-jhs-log" ? "yarn-jhs-redirect-log" : "yarn-redirect-log" return Ember.RSVP.hash({ - logs: this.store - .query(queryName, { - containerId: containerId - }) - .catch(function() { - return Ember.A(); + logs: this.resolveRedirectableQuery( + this.store.query(queryName, { containerId }), + m => { + return m.map(model => model.get('redirectedUrl'))[0]; + }, + url => { + return this.store.query(redirectQuery, url); }) }); }, fetchContentForLogFile(id) { let queryName = this.fallbackToJHS ? 'yarn-app-jhs-log' : 'yarn-app-log'; + let redirectQuery = queryName === "yarn-app-jhs-log" ? "yarn-app-jhs-redirect-log" : "yarn-app-redirect-log" return Ember.RSVP.hash({ - logs: this.store.findRecord(queryName, id) + logs: this.resolveRedirectableQuery( + this.store.findRecord(queryName, id), + m => { + return m.get('redirectedUrl') + }, + url => { + return this.store.findRecord(redirectQuery, url + Constants.PARAM_SEPARATOR + id) + }) }); }, + resolveRedirectableQuery(initial, urlResolver, redirectResolver) { + return initial.then(m => { + let redirectedUrl = urlResolver(m); + if (redirectedUrl !== null && redirectedUrl !== undefined && redirectedUrl !== '') { + let logFromRedirect = redirectResolver(redirectedUrl); + return Promise.all([m, logFromRedirect]); + } else { + return Promise.all([m, null]); + } + }) + .then(([originalLog, logFromRedirect]) => { + return logFromRedirect !== null ? logFromRedirect : originalLog; + }) + .catch(function () { + return Ember.A(); + }); + }, + resetAfterRefresh() { this.set("selectedAttemptId", ""); this.set("attemptContainerList", null); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-jhs-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-jhs-log.js index 31cf61ecbcd..87b9fa69d88 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-jhs-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-jhs-log.js @@ -19,7 +19,8 @@ import DS from 'ember-data'; export default DS.Model.extend({ - logs: DS.attr('string'), - containerID: DS.attr('string'), - logFileName: DS.attr('string') + logs: DS.attr('string', {defaultValue: ''}), + containerID: DS.attr('string', {defaultValue: ''}), + logFileName: DS.attr('string', {defaultValue: ''}), + redirectedUrl: DS.attr('string', {defaultValue: ''}), }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-jhs-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-jhs-redirect-log.js new file mode 100644 index 00000000000..87b9fa69d88 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-jhs-redirect-log.js @@ -0,0 +1,26 @@ +/** + * 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. + */ + +import DS from 'ember-data'; + +export default DS.Model.extend({ + logs: DS.attr('string', {defaultValue: ''}), + containerID: DS.attr('string', {defaultValue: ''}), + logFileName: DS.attr('string', {defaultValue: ''}), + redirectedUrl: DS.attr('string', {defaultValue: ''}), +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-log.js index 31cf61ecbcd..87b9fa69d88 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-log.js @@ -19,7 +19,8 @@ import DS from 'ember-data'; export default DS.Model.extend({ - logs: DS.attr('string'), - containerID: DS.attr('string'), - logFileName: DS.attr('string') + logs: DS.attr('string', {defaultValue: ''}), + containerID: DS.attr('string', {defaultValue: ''}), + logFileName: DS.attr('string', {defaultValue: ''}), + redirectedUrl: DS.attr('string', {defaultValue: ''}), }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-redirect-log.js new file mode 100644 index 00000000000..87b9fa69d88 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-app-redirect-log.js @@ -0,0 +1,26 @@ +/** + * 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. + */ + +import DS from 'ember-data'; + +export default DS.Model.extend({ + logs: DS.attr('string', {defaultValue: ''}), + containerID: DS.attr('string', {defaultValue: ''}), + logFileName: DS.attr('string', {defaultValue: ''}), + redirectedUrl: DS.attr('string', {defaultValue: ''}), +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-jhs-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-jhs-log.js index f022bc718b5..ab96c075d40 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-jhs-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-jhs-log.js @@ -19,9 +19,10 @@ import DS from 'ember-data'; export default DS.Model.extend({ - fileName: DS.attr('string'), - fileSize: DS.attr('string'), - lastModifiedTime: DS.attr('string'), - containerId: DS.attr('string'), - nodeId: DS.attr('string') + fileName: DS.attr('string', {defaultValue: ''}), + fileSize: DS.attr('string', {defaultValue: ''}), + lastModifiedTime: DS.attr('string', {defaultValue: ''}), + containerId: DS.attr('string', {defaultValue: ''}), + nodeId: DS.attr('string', {defaultValue: ''}), + redirectedUrl: DS.attr('string', {defaultValue: ''}) }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-jhs-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-jhs-redirect-log.js new file mode 100644 index 00000000000..ab96c075d40 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-jhs-redirect-log.js @@ -0,0 +1,28 @@ +/** + * 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. + */ + +import DS from 'ember-data'; + +export default DS.Model.extend({ + fileName: DS.attr('string', {defaultValue: ''}), + fileSize: DS.attr('string', {defaultValue: ''}), + lastModifiedTime: DS.attr('string', {defaultValue: ''}), + containerId: DS.attr('string', {defaultValue: ''}), + nodeId: DS.attr('string', {defaultValue: ''}), + redirectedUrl: DS.attr('string', {defaultValue: ''}) +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-log.js index f022bc718b5..ab96c075d40 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-log.js @@ -19,9 +19,10 @@ import DS from 'ember-data'; export default DS.Model.extend({ - fileName: DS.attr('string'), - fileSize: DS.attr('string'), - lastModifiedTime: DS.attr('string'), - containerId: DS.attr('string'), - nodeId: DS.attr('string') + fileName: DS.attr('string', {defaultValue: ''}), + fileSize: DS.attr('string', {defaultValue: ''}), + lastModifiedTime: DS.attr('string', {defaultValue: ''}), + containerId: DS.attr('string', {defaultValue: ''}), + nodeId: DS.attr('string', {defaultValue: ''}), + redirectedUrl: DS.attr('string', {defaultValue: ''}) }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-redirect-log.js new file mode 100644 index 00000000000..ab96c075d40 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-redirect-log.js @@ -0,0 +1,28 @@ +/** + * 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. + */ + +import DS from 'ember-data'; + +export default DS.Model.extend({ + fileName: DS.attr('string', {defaultValue: ''}), + fileSize: DS.attr('string', {defaultValue: ''}), + lastModifiedTime: DS.attr('string', {defaultValue: ''}), + containerId: DS.attr('string', {defaultValue: ''}), + nodeId: DS.attr('string', {defaultValue: ''}), + redirectedUrl: DS.attr('string', {defaultValue: ''}) +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-jhs-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-jhs-log.js index 3cfabd38186..716526cdc66 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-jhs-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-jhs-log.js @@ -28,9 +28,10 @@ export default DS.JSONAPISerializer.extend({ id: id, type: primaryModelClass.modelName, attributes: { - logs: payload, + logs: payload.data, containerID: splits[0], - logFileName: splits[1] + logFileName: splits[1], + redirectedUrl: payload.redirectedUrl } }; return { data: convertedPayload }; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-jhs-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-jhs-redirect-log.js new file mode 100644 index 00000000000..4bfc5b470b4 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-jhs-redirect-log.js @@ -0,0 +1,38 @@ +/** + * 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. + */ + +import DS from 'ember-data'; +import Converter from 'yarn-ui/utils/converter'; + +export default DS.JSONAPISerializer.extend({ + normalizeSingleResponse(store, primaryModelClass, payload, id/*, requestType*/) { + // Convert plain text response into JSON. + // ID is of the form containerId!fileName + var splits = Converter.splitForAppLogs(id); + var convertedPayload = { + id: id, + type: primaryModelClass.modelName, + attributes: { + logs: payload, + containerID: splits[1], + logFileName: splits[2] + } + }; + return { data: convertedPayload }; + }, +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-log.js index 3cfabd38186..716526cdc66 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-log.js @@ -28,9 +28,10 @@ export default DS.JSONAPISerializer.extend({ id: id, type: primaryModelClass.modelName, attributes: { - logs: payload, + logs: payload.data, containerID: splits[0], - logFileName: splits[1] + logFileName: splits[1], + redirectedUrl: payload.redirectedUrl } }; return { data: convertedPayload }; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-redirect-log.js new file mode 100644 index 00000000000..4bfc5b470b4 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-app-redirect-log.js @@ -0,0 +1,38 @@ +/** + * 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. + */ + +import DS from 'ember-data'; +import Converter from 'yarn-ui/utils/converter'; + +export default DS.JSONAPISerializer.extend({ + normalizeSingleResponse(store, primaryModelClass, payload, id/*, requestType*/) { + // Convert plain text response into JSON. + // ID is of the form containerId!fileName + var splits = Converter.splitForAppLogs(id); + var convertedPayload = { + id: id, + type: primaryModelClass.modelName, + attributes: { + logs: payload, + containerID: splits[1], + logFileName: splits[2] + } + }; + return { data: convertedPayload }; + }, +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-container.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-container.js index 599cf7f23c1..d5c81a9371e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-container.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-container.js @@ -45,7 +45,7 @@ export default DS.JSONAPISerializer.extend({ }, normalizeArrayResponse(store, primaryModelClass, payload/*, id, requestType*/) { - + payload = payload["containerLogsInfo"] var normalizedArrayResponse = { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-log.js index c785f7bbc96..f9db7b9e4b0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-log.js @@ -26,6 +26,7 @@ export default DS.JSONAPISerializer.extend({ fileName: payload.fileName, fileSize: payload.fileSize, lastModifiedTime: payload.lastModifiedTime, + redirectedUrl: payload.redirectedUrl, containerId: containerId, nodeId: nodeId } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-redirect-log.js new file mode 100644 index 00000000000..f9db7b9e4b0 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-jhs-redirect-log.js @@ -0,0 +1,57 @@ +/** + * 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. + */ +import DS from 'ember-data'; + +export default DS.JSONAPISerializer.extend({ + internalNormalizeSingleResponse(store, primaryModelClass, payload, containerId, nodeId) { + var fixedPayload = { + id: "yarn_log_" + payload.fileName + "_" + Date.now(), + type: primaryModelClass.modelName, + attributes: { + fileName: payload.fileName, + fileSize: payload.fileSize, + lastModifiedTime: payload.lastModifiedTime, + redirectedUrl: payload.redirectedUrl, + containerId: containerId, + nodeId: nodeId + } + }; + return fixedPayload; + }, + + normalizeArrayResponse(store, primaryModelClass, payload/*, id, requestType*/) { + var normalizedArrayResponse = { + data: [] + }; + // If JSON payload is an object with a containerLogsInfo property + if (payload && payload.containerLogsInfo && payload.containerLogsInfo.containerLogInfo) { + normalizedArrayResponse.data = payload.containerLogsInfo.containerLogInfo.map((signle_payload) => { + return this.internalNormalizeSingleResponse(store, primaryModelClass, signle_payload, + payload.containerLogsInfo.containerId, payload.containerLogsInfo.nodeId); + }); + } + // If JSON payload is an array + if (payload && payload[0] && payload[0].containerLogInfo) { + normalizedArrayResponse.data = payload[0].containerLogInfo.map((signle_payload) => { + return this.internalNormalizeSingleResponse(store, primaryModelClass, signle_payload, + payload[0].containerId, payload[0].nodeId); + }); + } + return normalizedArrayResponse; + } +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-redirect-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-redirect-log.js new file mode 100644 index 00000000000..c41170870fa --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-redirect-log.js @@ -0,0 +1,54 @@ +/** + * 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. + */ +import DS from 'ember-data'; + +export default DS.JSONAPISerializer.extend({ + internalNormalizeSingleResponse(store, primaryModelClass, payload, containerId, nodeId) { + var fixedPayload = { + id: "yarn_log_" + payload.fileName + "_" + Date.now(), + type: primaryModelClass.modelName, + attributes: { + fileName: payload.fileName, + fileSize: payload.fileSize, + lastModifiedTime: payload.lastModifiedTime, + containerId: containerId, + nodeId: nodeId + } + }; + return fixedPayload; + }, + + normalizeArrayResponse(store, primaryModelClass, payload/*, id, requestType*/) { + var normalizedArrayResponse = { + data: [] + }; + if (payload && payload.containerLogsInfo && payload.containerLogsInfo.containerLogInfo) { + normalizedArrayResponse.data = payload.containerLogsInfo.containerLogInfo.map((paylog) => { + return this.internalNormalizeSingleResponse(store, primaryModelClass, paylog, + payload.containerLogsInfo.containerId, payload.containerLogsInfo.nodeId); + }); + } + if (payload && payload[0] && payload[0].containerLogInfo) { + normalizedArrayResponse.data = payload[0].containerLogInfo.map((paylog) => { + return this.internalNormalizeSingleResponse(store, primaryModelClass, paylog, + payload[0].containerId, payload[0].nodeId); + }); + } + return normalizedArrayResponse; + } +});