2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.netconf.monitoring.xml.model;
10 import javax.xml.bind.annotation.XmlElement;
11 import javax.xml.bind.annotation.XmlTransient;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.Session1;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
15 import org.opendaylight.yangtools.yang.common.QName;
17 final class MonitoringSession {
20 private Session managementSession;
22 public MonitoringSession(Session managementSession) {
23 this.managementSession = managementSession;
26 public MonitoringSession() {
29 public void setManagementSession(Session managementSession) {
30 this.managementSession = managementSession;
33 @XmlElement(name = "session-id")
35 return managementSession.getSessionId();
38 @XmlElement(name = "source-host")
39 public String getSourceHost() {
40 return managementSession.getSourceHost().getDomainName().getValue();
43 @XmlElement(name = "login-time")
44 public String getLoginTime() {
45 return managementSession.getLoginTime().getValue();
48 @XmlElement(name = "in-bad-rpcs")
49 public Long getInBadRpcs() {
50 return managementSession.getInBadRpcs().getValue();
53 @XmlElement(name = "in-rpcs")
54 public Long getInRpcs() {
55 return managementSession.getInRpcs().getValue();
58 @XmlElement(name = "out-notifications")
59 public Long getOutNotifications() {
60 return managementSession.getOutNotifications().getValue();
63 @XmlElement(name = "out-rpc-errors")
64 public Long getOutRpcErrors() {
65 return managementSession.getOutRpcErrors().getValue();
68 @XmlElement(name = "transport")
69 public String getTransport() {
71 QName qName = (QName) managementSession.getTransport().getField("QNAME").get(null);
72 return qName.getLocalName();
73 } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
74 throw new IllegalArgumentException("Unknown transport type " + managementSession.getTransport(), e);
78 @XmlElement(name= "session-identifier")
79 public String getSessionType() {
80 return managementSession.getAugmentation(Session1.class).getSessionIdentifier();
83 @XmlElement(name = "username")
84 public String getUsername() {
85 return managementSession.getUsername();