⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netlogwriter.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*   Derby - Class org.apache.derby.client.net.NetLogWriter   Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable.   Licensed 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.derby.client.net;// network traffic tracer.// This class traces communication buffers for both sends and receives.// The value of the hex bytes are traced along with the ascii and ebcdic translations.public class NetLogWriter extends org.apache.derby.client.am.LogWriter {    // The recevie constant is used to indicate that the bytes were read to a Stream.    // It indicates to this class that a receive header should be used.    public static final int TYPE_TRACE_RECEIVE = 2;    // The send constant is used to indicate that the bytes were written to    // a Stream.  It indicates to this class that a send header should be used.    public static final int TYPE_TRACE_SEND = 1;    //------------------------------ internal constants --------------------------    // This class was implemented using character arrays to translate bytes    // into ascii and ebcdic.  The goal was to be able to quickly index into the    // arrays to find the characters.  Char arrays instead of strings were used as    // much as possible in an attempt to help speed up performance.    // An array of characters used to translate bytes to ascii.    // The position in the array corresponds to the hex value of the character.    private static final char asciiChar__ [] = {        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //0        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //1        ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', //2        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', //3        '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', //4        'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', //5        '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', //6        'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '.', //7        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //8        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //9        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //A        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //B        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //C        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //D        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //E        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'   //F    };    // This column position header is used to mark offsets into the trace.    private static final String colPosHeader__ =            "       0 1 2 3 4 5 6 7   8 9 A B C D E F   0123456789ABCDEF  0123456789ABCDEF";    // An array of characters used to translate bytes to ebcdic.    // The position in the array corresponds to the hex value of the    // character.    private static final char ebcdicChar__[] = {        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //0        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //1        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //2        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //3        ' ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '<', '(', '+', '|', //4        '&', '.', '.', '.', '.', '.', '.', '.', '.', '.', '!', '$', '*', ')', ';', '.', //5        '-', '/', '.', '.', '.', '.', '.', '.', '.', '.', '|', ',', '%', '_', '>', '?', //6        '.', '.', '.', '.', '.', '.', '.', '.', '.', '`', ':', '#', '@', '\'', '=', '"', //7        '.', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '.', '.', '.', '.', '.', '.', //8        '.', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', '.', '.', '.', '.', '.', '.', //9        '.', '~', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', '.', '.', '.', '.', '.', //A        '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', //B        '{', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '.', '.', '.', '.', '.', '.', //C        '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '.', '.', '.', '.', '.', '.', //D        '\\', '.', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '.', '.', '.', '.', '.', '.', //E        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '.', '.', '.', '.', '.'   //F    };    // An array of characters representing hex numbers.    private static final char hexDigit__ [] = {        '0', '1', '2', '3', '4', '5', '6', '7',        '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'    };    // The receive header comes befor bytes which would be read from a stream.    private static final String receiveHeader__ =            "       RECEIVE BUFFER:                     (ASCII)           (EBCDIC)";    // The send header comes before bytes which would be written to a stream.    private static final String sendHeader__ =            "       SEND BUFFER:                        (ASCII)           (EBCDIC)";    private static final char spaceChar__ = ' ';    private static final char zeroChar__ = '0';    // This mapping table associates a codepoint to a String describing the codepoint.    // This is needed because the trace prints the first codepoint in send and receive buffers.    // This is created lazily because there is no need to create the mapping if tracing isn't used.    // So this array will only be created when the com buffer trace is started.    private static CodePointNameTable codePointNameTable__ = null;    //-----------------------------internal state---------------------------------    //-----------------------------constructors/finalizer-------------------------    // One NetLogWriter object is created per data source, iff tracing is enabled.    public NetLogWriter(java.io.PrintWriter printWriter, int traceLevel) {        super(printWriter, traceLevel);        // Initialize the codepoint name table if not previously initialized.        // This is done lazily so that it is not created if the trace isn't used (save some init time).        if (codePointNameTable__ == null) {            codePointNameTable__ = new CodePointNameTable();        }    }    //------------------------------entry points----------------------------------    // Specialization of LogWriter.traceConnectsExit()    public void traceConnectsExit(org.apache.derby.client.am.Connection connection) {        if (traceSuspended()) {            return;        }        NetConnection c = (NetConnection) connection;        synchronized (printWriter_) {            super.traceConnectsExit(c);            dncnetprint("  PROTOCOL manager levels: { ");            printWriter_.print("SQLAM=" + c.getSQLAM() + ", ");            printWriter_.print("AGENT=" + c.getAGENT() + ", ");            printWriter_.print("CMNTCPIP=" + c.getCMNTCPIP() + ", ");            printWriter_.print("RDB=" + c.getRDB() + ", ");            printWriter_.print("SECMGR=" + c.getSECMGR() + ", ");            printWriter_.print("XAMGR=" + c.getXAMGR() + ", ");            printWriter_.print("SYNCPTMGR=" + c.getSYNCPTMGR() + ", ");            printWriter_.print("RSYNCMGR=" + c.getRSYNCMGR());            printWriter_.println(" }");            printWriter_.flush();        }    }    public void traceConnectsResetExit(org.apache.derby.client.am.Connection connection) {        if (traceSuspended()) {            return;        }        NetConnection c = (NetConnection) connection;        synchronized (printWriter_) {            super.traceConnectsResetExit(c);            dncnetprint("  PROTOCOL manager levels: { ");            printWriter_.print("SQLAM=" + c.getSQLAM() + ", ");            printWriter_.print("AGENT=" + c.getAGENT() + ", ");            printWriter_.print("CMNTCPIP=" + c.getCMNTCPIP() + ", ");            printWriter_.print("RDB=" + c.getRDB() + ", ");            printWriter_.print("SECMGR=" + c.getSECMGR() + ", ");            printWriter_.print("XAMGR=" + c.getXAMGR() + ", ");            printWriter_.print("SYNCPTMGR=" + c.getSYNCPTMGR() + ", ");            printWriter_.print("RSYNCMGR=" + c.getRSYNCMGR());            printWriter_.println(" }");            printWriter_.flush();        }    }    // Pass the connection handle and print it in the header    // What exactly is supposed to be passed,  assume one complete DSS packet    // Write the communication buffer data to the trace.    // The data is passed in via a byte array.  The start and length of the data is given.    // The type is needed to indicate if the data is part of the send or receive buffer.    // The class name, method name, and trcPt number are also written to the trace.    // Not much checking is performed on the parameters.  This is done to help performance.    synchronized public void traceProtocolFlow(byte[] buff,                                               int offset,                                               int len,                                               int type,                                               String className,                                               String methodName,                                               int tracepoint) {        if (traceSuspended()) {            return;        }        if (!loggingEnabled(org.apache.derby.jdbc.ClientDataSource.TRACE_PROTOCOL_FLOWS)) {            return;        }        synchronized (printWriter_) {            super.tracepoint("[net]", tracepoint, className, methodName);            int fullLen = len;            boolean printColPos = true;            while (fullLen >= 2) { // format each DssHdr seperately                // get the length of this DssHdr                len = ((buff[offset] & 0xff) << 8) + ((buff[offset + 1] & 0xff) << 0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -