PageRenderTime 28ms CodeModel.GetById 14ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/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
17package com.hazelcast.impl.management;
18
19import com.hazelcast.core.Hazelcast;
20import com.hazelcast.logging.ILogger;
21
22import java.io.DataInput;
23import java.io.DataOutput;
24import java.io.IOException;
25import java.io.InputStream;
26import java.util.Properties;
27import java.util.logging.Level;
28
29// author: sancar - 17.12.2012
30public class VersionMismatchLogRequest implements ConsoleRequest {
31
32    private String manCenterVersion;
33
34    public VersionMismatchLogRequest(String manCenterVersion){
35        this.manCenterVersion = manCenterVersion;
36    }
37
38    public VersionMismatchLogRequest(){
39        super();
40    }
41
42    public int getType() {
43        return ConsoleRequestConstants.REQUEST_TYPE_LOG_VERSION_MISMATCH;
44    }
45
46    public Object readResponse(DataInput in) throws IOException {
47        return "SUCCESS";
48    }
49
50    public void writeResponse(ManagementCenterService mcs, DataOutput dos) throws Exception {
51        final ILogger logger = mcs.getHazelcastInstance().node.getLogger(VersionMismatchLogRequest.class.getName());
52        mcs.setVersionMismatch(true);
53        String hazelcastVersion = mcs.getHazelcastInstance().node.initializer.getVersion();
54        logger.log(Level.SEVERE, "Version Mismatch\n"
55                                 + "\tmanagement center version : "+ manCenterVersion  + "\n"
56                                 + "\thazelcast version : "+ hazelcastVersion);
57    }
58
59    public void writeData(DataOutput out) throws IOException {
60        out.writeUTF(manCenterVersion);
61    }
62
63    public void readData(DataInput in) throws IOException {
64        manCenterVersion = in.readUTF();
65    }
66}