static void saNtfNotificationCallback(SaNtfSubscriptionIdT subscriptionId, const SaNtfNotificationsT *notification)
{
	SaInt32T i;
	SaNtfNotificationHandleT notificationHandle;
	const SaNtfNotificationHeaderT *notificationHeader;

	switch (notification->notificationType) {
	case SA_NTF_TYPE_ALARM:
		notificationHandle = notification->notification.alarmNotification.notificationHandle;
		notificationHeader = &notification->notification.alarmNotification.notificationHeader;
		printf("===  %s - Alarm  ===\n", event_time(*notificationHeader->eventTime));
		print_header(notificationHeader, subscriptionId, notification->notificationType);
		print_additional_info(notificationHandle, notificationHeader);
		print_probable_cause(*(notification->notification.alarmNotification.probableCause));
		print_severity(*(notification->notification.alarmNotification.perceivedSeverity));

		break;

	case SA_NTF_TYPE_STATE_CHANGE:
		notificationHandle = notification->notification.stateChangeNotification.notificationHandle;
		notificationHeader = &notification->notification.stateChangeNotification.notificationHeader;
		printf("===  %s - State Change  ===\n", event_time(*notificationHeader->eventTime));
		print_header(notificationHeader, subscriptionId, notification->notificationType);
		print_additional_info(notificationHandle, notificationHeader);
		print_source_indicator(*(notification->notification.stateChangeNotification.sourceIndicator));

		if (verbose)
			printf("Num of StateChanges: %d\n", notification->notification.stateChangeNotification.numStateChanges);

		/* Changed states */
		for (i = 0; i < notification->notification.stateChangeNotification.numStateChanges; i++) {
			print_change_states(notificationHeader->notificationClassId,
				&notification->notification.stateChangeNotification.changedStates[i]);
		}
		break;

	case SA_NTF_TYPE_OBJECT_CREATE_DELETE:
		notificationHandle = notification->notification.objectCreateDeleteNotification.notificationHandle;
		notificationHeader = &notification->notification.objectCreateDeleteNotification.notificationHeader;
		printf("===  %s - Object Create/Delete  ===\n", event_time(*notificationHeader->eventTime));
		print_header(notificationHeader, subscriptionId, notification->notificationType);
		print_source_indicator(*(notification->notification.objectCreateDeleteNotification.sourceIndicator));
		printf("numAttributes: %d\n", notification->notification.objectCreateDeleteNotification.numAttributes);

		/* Object Attributes */
		for (i = 0; i < notification->notification.objectCreateDeleteNotification.numAttributes; i++) {
			print_object_attributes(&notification->notification.
						objectCreateDeleteNotification.objectAttributes[i]);
		}
		break;

	case SA_NTF_TYPE_ATTRIBUTE_CHANGE:
		notificationHandle = notification->notification.attributeChangeNotification.notificationHandle;
		notificationHeader = &notification->notification.attributeChangeNotification.notificationHeader;
		printf("===  %s - Attribute Change  ===\n", event_time(*notificationHeader->eventTime));
		print_header(notificationHeader, subscriptionId, notification->notificationType);
		print_source_indicator(*(notification->notification.attributeChangeNotification.sourceIndicator));
		printf("numAttributes: %d\n", notification->notification.attributeChangeNotification.numAttributes);

		/* Changed Attributes */
		for (i = 0; i < notification->notification.attributeChangeNotification.numAttributes; i++) {
			print_changed_attributes(&notification->notification.
						 attributeChangeNotification.changedAttributes[i]);
		}
		break;

	case SA_NTF_TYPE_SECURITY_ALARM:
		notificationHandle = notification->notification.securityAlarmNotification.notificationHandle;
		notificationHeader = &notification->notification.securityAlarmNotification.notificationHeader;
		printf("===  %s - Security Alarm  ===\n", event_time(*notificationHeader->eventTime));
		print_header(notificationHeader, subscriptionId, notification->notificationType);
		print_probable_cause(*(notification->notification.securityAlarmNotification.probableCause));
		print_severity(*(notification->notification.securityAlarmNotification.severity));
		print_security_alarm_types((SaNtfSecurityAlarmNotificationT *)&notification->notification.
					   securityAlarmNotification);

		break;

	default:
		printf("unknown notification type %d", (int)notification->notificationType);
		break;
	}

	switch (notification->notificationType) {
	case SA_NTF_TYPE_ALARM:
		saNtfNotificationFree(notification->notification.alarmNotification.notificationHandle);
		break;
	case SA_NTF_TYPE_SECURITY_ALARM:
		saNtfNotificationFree(notification->notification.securityAlarmNotification.notificationHandle);
		break;
	case SA_NTF_TYPE_STATE_CHANGE:
		saNtfNotificationFree(notification->notification.stateChangeNotification.notificationHandle);
		break;
	case SA_NTF_TYPE_OBJECT_CREATE_DELETE:
		saNtfNotificationFree(notification->notification.objectCreateDeleteNotification.notificationHandle);
		break;
	case SA_NTF_TYPE_ATTRIBUTE_CHANGE:
		saNtfNotificationFree(notification->notification.attributeChangeNotification.notificationHandle);
		break;

	default:
		printf("wrong type");
		assert(0);
	}
	printf("\n");
}
Beispiel #2
0
static int print_keyval_pair(TROVE_keyval_s *key_p,
			     TROVE_keyval_s *val_p,
			     TROVE_ds_type type,
			     int sz)
{
    int key_printable = 0, val_printable = 0;

    if (isprint(((char *)key_p->buffer)[0]) && (strnlen(key_p->buffer, sz) < 64)) key_printable = 1;
    if (isprint(((char *)val_p->buffer)[0]) && (strnlen(val_p->buffer, sz) < 64)) val_printable = 1;

    if (!strncmp(key_p->buffer, "metadata", 9) && val_p->read_sz == sizeof(struct PVFS_object_attr)) {
	fprintf(stdout,
		"\t\t'%s' (%d): '%s' (%d) as PVFS_object_attr = ",
		(char *) key_p->buffer,
		key_p->read_sz,
		(char *) val_p->buffer,
		val_p->read_sz);
	print_object_attributes((struct PVFS_object_attr *) val_p->buffer);
    }
    else if (!strncmp(key_p->buffer, "dh", 17) && val_p->read_sz % sizeof(PVFS_handle) == 0) {
	fprintf(stdout,
		"\t\t'%s' (%d): '%s' (%d) as handles = ",
		(char *) key_p->buffer,
		key_p->read_sz,
		(char *) val_p->buffer,
		val_p->read_sz);
	print_datafile_handles((PVFS_handle *) val_p->buffer, val_p->read_sz / sizeof(PVFS_handle));
    }
    else if (type == PVFS_TYPE_DIRECTORY && !strncmp(key_p->buffer, "de", 3)) {
	fprintf(stdout,
		"\t\t'%s' (%d): '%s' (%d) as a handle = 0x%08llx\n",
		(char *) key_p->buffer,
		key_p->read_sz,
		(char *) val_p->buffer,
		val_p->read_sz,
		llu(*(TROVE_handle *) val_p->buffer));
    }
    else if (type == PVFS_TYPE_DIRDATA && val_p->read_sz == 8) {
	fprintf(stdout,
		"\t\t'%s' (%d): '%s' (%d) as a handle = 0x%08llx\n",
		(char *) key_p->buffer,
		key_p->read_sz,
		(char *) val_p->buffer,
		val_p->read_sz,
		llu(*(TROVE_handle *) val_p->buffer));
    }
    else if (key_printable && val_printable) {
	fprintf(stdout,
		"\t\t'%s' (%d): '%s' (%d)\n",
		(char *) key_p->buffer,
		key_p->read_sz,
		(char *) val_p->buffer,
		val_p->read_sz);
    }
    else if (key_printable && !val_printable) {
	fprintf(stdout,
		"\t\t'%s' (%d): <data> (%d)\n",
		(char *) key_p->buffer,
		key_p->read_sz,
		val_p->read_sz);
    }
    else {
	fprintf(stdout,
		"\t\t<data> (%d): <data> (%d)\n",
		key_p->read_sz,
		val_p->read_sz);
    }
    return 0;
}