/hazelcast/src/main/java/com/hazelcast/impl/management/VersionMismatchLogRequest.java

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 66 lines · 38 code · 12 blank · 16 comment · 0 complexity · 185283ef10eeaef525d37fa8f7454762 MD5 · raw file

  1. /*
  2. * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.hazelcast.impl.management;
  17. import com.hazelcast.core.Hazelcast;
  18. import com.hazelcast.logging.ILogger;
  19. import java.io.DataInput;
  20. import java.io.DataOutput;
  21. import java.io.IOException;
  22. import java.io.InputStream;
  23. import java.util.Properties;
  24. import java.util.logging.Level;
  25. // author: sancar - 17.12.2012
  26. public class VersionMismatchLogRequest implements ConsoleRequest {
  27. private String manCenterVersion;
  28. public VersionMismatchLogRequest(String manCenterVersion){
  29. this.manCenterVersion = manCenterVersion;
  30. }
  31. public VersionMismatchLogRequest(){
  32. super();
  33. }
  34. public int getType() {
  35. return ConsoleRequestConstants.REQUEST_TYPE_LOG_VERSION_MISMATCH;
  36. }
  37. public Object readResponse(DataInput in) throws IOException {
  38. return "SUCCESS";
  39. }
  40. public void writeResponse(ManagementCenterService mcs, DataOutput dos) throws Exception {
  41. final ILogger logger = mcs.getHazelcastInstance().node.getLogger(VersionMismatchLogRequest.class.getName());
  42. mcs.setVersionMismatch(true);
  43. String hazelcastVersion = mcs.getHazelcastInstance().node.initializer.getVersion();
  44. logger.log(Level.SEVERE, "Version Mismatch\n"
  45. + "\tmanagement center version : "+ manCenterVersion + "\n"
  46. + "\thazelcast version : "+ hazelcastVersion);
  47. }
  48. public void writeData(DataOutput out) throws IOException {
  49. out.writeUTF(manCenterVersion);
  50. }
  51. public void readData(DataInput in) throws IOException {
  52. manCenterVersion = in.readUTF();
  53. }
  54. }