Search in sources :

Example 1 with Builder

use of com.ibm.dtfj.image.j9.Builder in project openj9 by eclipse.

the class XMLIndexReader method setJ9DumpData.

public void setJ9DumpData(long environ, String osType, String osSubType, String cpuType, int cpuCount, long bytesMem, int pointerSize, Image[] imageRef, ImageAddressSpace[] addressSpaceRef, ImageProcess[] processRef) {
    Builder builder = null;
    if (_stream == null) {
        // extract directly from the file
        builder = new Builder(_coreFile, _reader, environ, _fileResolvingAgent);
    } else {
        // extract using the data stream
        builder = new Builder(_coreFile, _stream, environ, _fileResolvingAgent);
    }
    _coreFile.extract(builder);
    // Jazz 4961 : chamlain : NumberFormatException opening corrupt dump
    if (cpuType == null)
        cpuType = builder.getCPUType();
    String cpuSubType = builder.getCPUSubType();
    if (osType == null)
        osType = builder.getOSType();
    long creationTime = builder.getCreationTime();
    _coreImage = new Image(osType, osSubType, cpuType, cpuSubType, cpuCount, bytesMem, creationTime);
    ImageAddressSpace addressSpace = (ImageAddressSpace) builder.getAddressSpaces().next();
    ImageProcess process = (ImageProcess) addressSpace.getCurrentProcess();
    // If not sure, use the first address space/process pair found
    for (Iterator it = builder.getAddressSpaces(); it.hasNext(); ) {
        ImageAddressSpace addressSpace1 = (ImageAddressSpace) it.next();
        final boolean vb = false;
        if (vb)
            System.out.println("address space " + addressSpace1);
        _coreImage.addAddressSpace(addressSpace1);
        for (Iterator it2 = addressSpace1.getProcesses(); it2.hasNext(); ) {
            ImageProcess process1 = (ImageProcess) it2.next();
            if (vb)
                try {
                    System.out.println("process " + process1.getID());
                } catch (DataUnavailable e) {
                } catch (CorruptDataException e) {
                }
            if (process == null || isProcessForEnvironment(environ, addressSpace1, process1)) {
                addressSpace = addressSpace1;
                process = process1;
                if (vb)
                    System.out.println("default process for Runtime");
            }
        }
    }
    if (null != process) {
        // z/OS can have 64-bit or 31-bit processes, Java only reports 64-bit or 32-bit.
        if (process.getPointerSize() != pointerSize && !(process.getPointerSize() == 31 && pointerSize == 32)) {
            System.out.println("XML and core file pointer sizes differ " + process.getPointerSize() + "!=" + pointerSize);
        }
    } else {
        throw new IllegalStateException("No process found in the dump.");
    }
    imageRef[0] = _coreImage;
    addressSpaceRef[0] = addressSpace;
    processRef[0] = process;
}
Also used : ImageAddressSpace(com.ibm.dtfj.image.j9.ImageAddressSpace) ImageProcess(com.ibm.dtfj.image.j9.ImageProcess) Builder(com.ibm.dtfj.image.j9.Builder) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Image(com.ibm.dtfj.image.j9.Image)

Example 2 with Builder

use of com.ibm.dtfj.image.j9.Builder in project dubbo by alibaba.

the class ProtobufUtils method deserializeJson.

/* Protobuf json */
static <T> T deserializeJson(String json, Class<T> requestClass) throws InvalidProtocolBufferException {
    Builder builder;
    try {
        builder = getMessageBuilder(requestClass);
    } catch (Exception e) {
        throw new IllegalArgumentException("Get google protobuf message builder from " + requestClass.getName() + "failed", e);
    }
    JsonFormat.parser().merge(json, builder);
    return (T) builder.build();
}
Also used : MessageOrBuilder(com.google.protobuf.MessageOrBuilder) Builder(com.google.protobuf.GeneratedMessageV3.Builder) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IOException(java.io.IOException)

Example 3 with Builder

use of com.ibm.dtfj.image.j9.Builder in project openj9 by eclipse.

the class XMLIndexReader method _createCoreImageAfterParseError.

/**
 * This is like the setJ9DumpData method but is to be used when we fail to parse the file.  It is meant to try to construct the
 * Image object with what it was able to get
 *
 * @param e The cause of the error
 */
private void _createCoreImageAfterParseError(Exception e) {
    Builder builder = null;
    if (_stream == null) {
        // extract directly from the file
        builder = new Builder(_coreFile, _reader, 0, _fileResolvingAgent);
    } else {
        // extract using the data stream
        builder = new Builder(_coreFile, _stream, 0, _fileResolvingAgent);
    }
    _coreFile.extract(builder);
    String osType = builder.getOSType();
    String cpuType = builder.getCPUType();
    String cpuSubType = builder.getCPUSubType();
    long creationTime = builder.getCreationTime();
    _coreImage = new Image(osType, null, cpuType, cpuSubType, 0, 0, creationTime);
    Iterator spaces = builder.getAddressSpaces();
    while (spaces.hasNext()) {
        ImageAddressSpace addressSpace = (ImageAddressSpace) spaces.next();
        // Set all processes as having invalid runtimes
        for (Iterator processes = addressSpace.getProcesses(); processes.hasNext(); ) {
            ImageProcess process = (ImageProcess) processes.next();
            process.runtimeExtractionFailed(e);
        }
        _coreImage.addAddressSpace(addressSpace);
    }
}
Also used : ImageAddressSpace(com.ibm.dtfj.image.j9.ImageAddressSpace) ImageProcess(com.ibm.dtfj.image.j9.ImageProcess) Builder(com.ibm.dtfj.image.j9.Builder) Iterator(java.util.Iterator) Image(com.ibm.dtfj.image.j9.Image)

Aggregations

Builder (com.ibm.dtfj.image.j9.Builder)2 Image (com.ibm.dtfj.image.j9.Image)2 ImageAddressSpace (com.ibm.dtfj.image.j9.ImageAddressSpace)2 ImageProcess (com.ibm.dtfj.image.j9.ImageProcess)2 Iterator (java.util.Iterator)2 Builder (com.google.protobuf.GeneratedMessageV3.Builder)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 MessageOrBuilder (com.google.protobuf.MessageOrBuilder)1 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)1 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)1 IOException (java.io.IOException)1